- Issue created by @dewalt
- 🇮🇳India hetal.solanki
@dewalt
I have review and try to apply patch and it's working for me.
So moving this issue to RTBC
Thank you!!
- First commit to issue fork.
- Merge request !79Issue #3501703: Warning: Invalid condition field = NULL → (Open) created by mparker17
- 🇨🇦Canada mparker17 UTC-4
The patch looks fine to me, but I'm having trouble reproducing the issue (and if I can reproduce it manually, then I can add a test) with the instructions provided, i.e.:
Add filter with "empty" condition to any Search Api view.
Looks like it also happens on 0 values of numeric filter.
@dewalt or @hetal.solanki, could either of you add some more details?
Here's what I've tried...
- Run the steps to set up a local environment, including apply the patch or switching to the issue fork (I used the issue fork but either will work)
- Edit the test view at
/admin/structure/views/view/test_elasticsearch_index_search
- Under Filter criteria, click the
Add
button - Check
Category
, click theAdd and configure filter criteria
button - Set Operator to
Is empty (NULL)
- Click the
Apply
button - Click the
Save
button on the view - Go to the test view at
/test-elasticsearch-index-search
- Observe that the results are filtered
- Go to
/admin/reports/dblog
- Expected behavior: I see the error
Invalid condition category = NULL
- Actual behavior: The error log is empty
- Expected behavior: I see the error
- Edit the test view at
/admin/structure/views/view/test_elasticsearch_index_search
- Under Filter criteria, choose
And/Or Rearrange
from the drop-button - Click
Remove
in the Test entity - mul changed revisions and data table datasource: Category = row, i.e.: to delete the test filter added in the previous test - Under Filter criteria, click the
Add
button - Check
Width
, click theAdd and configure filter criteria
button - Set Operator to
Is equal to
, and set Value to0
- Click the
Apply
button - Click the
Save
button on the view - Go to the test view at
/test-elasticsearch-index-search
- Observe that the results are filtered
- Go to
/admin/reports/dblog
- Expected behavior: I see the error
Invalid condition category = NULL
- Actual behavior: The error log is empty
- Expected behavior: I see the error
- 🇨🇦Canada mparker17 UTC-4
(whoops, wrong status, I should have changed it to "maintainer needs more info"... when you add more steps to reproduce, please change it back to RTBC)
- 🇫🇮Finland sokru
I guess it might be related by some faulty Search API configuration or source data issue, but on the other hand search_api_opensearch module has this change committed since day 0 https://git.drupalcode.org/project/search_api_opensearch/-/blob/3.x/src/...
- Status changed to Postponed: needs info
9 days ago 9:36am 29 July 2025 - 🇫🇷France vivibdev
I don't know how the view made the request.
But when you made a programmatically search_api query, this warning will trigger each time you search contains a condition with a null or false value.In src/SearchAPI/Query/FilterBuilder.php, the only way to trigger "exists" condition is to have a null value, but this null value triggers a warning earlier.
first the warning :
if (!$condition->getField() || !$condition->getValue() || !$condition->getOperator()) { // @todo When using views the sort field is coming as a filter and // messing with this section. $this->logger->warning("Invalid condition %condition", ['%condition' => $condition]); }
then the "exists" only if $condition->getValue() is null :
public function buildFilterTerm(Condition $condition, array $index_fields = []) { // Handles "empty", "not empty" operators. if (is_null($condition->getValue())) { return match ($condition->getOperator()) { '<>' => ['exists' => ['field' => $condition->getField()]], '=' => ['bool' => ['must_not' => ['exists' => ['field' => $condition->getField()]]]], default => throw new SearchApiException(sprintf('Invalid condition for field %s', $condition->getField())), }; }