Unknown key for a VALUE_NULL in [size]

Created on 20 April 2023, about 1 year ago
Updated 23 April 2023, about 1 year ago

Problem/Motivation

Views queries where the result limit is NULL or set to 'Display all results' are not being handled correctly.

  • I've encountered this issue using vbo_export, and a similar issue when using views_data_export. When trying to export the data to a csv views_data_export runs the following query using the Opensearch BackendClient:

    $view->query->getSearchApiQuery()->range(NULL, 1)->execute()->getResultCount();
  • I've also encountered this issue when creating a standard view page and set the pager to 'Display all results'.

It seems to me that setting a NULL value for either of the params in the range() method results in a value of NULL being submitted in the body of the opensearch request call:
array(2) { ["from"]=> int(0) ["size"]=> NULL }

I am getting the following error when submitting this request with opensearch 1.2.x:
{"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a VALUE_NULL in [size].","line":1,"col":18}],"type":"parsing_exception","reason":"Unknown key for a VALUE_NULL in [size].","line":1,"col":18},"status":400}

`Drupal\search_api\Query\QueryInterface::range()` indicates that "If called without parameters, this will remove all range restrictions previously set." This doesn't seem to be properly handled, however, and `QueryParamBuilder::buildQueryParams()` passes the null value to the body of the opensearch request call.

Steps to reproduce

Opensearch 1.2.x
drupal/views_data_export: 2.x
drupal/search_api: 1.x
drupal/search_api_opensearch: 1.x

  1. Install views_data_export
  2. Configure a search index
  3. Configure a view based on this search index
  4. Add a view display of type Data Export and configure it with at least some fields.

Proposed resolution

Only set the 'from' and 'size' params if the value is an integer, or fallback to the default.

Remaining tasks

  • Confirm this behaviour.
  • Increase parameter validation
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom kalpaitch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024