Repository navigation
fix(gql): render boolean where-filter lists as lowercase GraphQL literals - #2192
linhongyu510 wants to merge 1 commit into
Conversation
…rals Boolean where-filter lists (valueBooleanArray/valueBooleanList) were rendered via str(), emitting capitalized 'True'/'False', which is not a valid GraphQL boolean literal and breaks server-side query parsing. A single boolean value was already rendered correctly by _bool_to_str(); this applies the same lowercasing to list elements for consistency.
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
|
To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge. |
|
I agree to the Weaviate Contributor License Agreement. Transparency note: this change was prepared with AI assistance (bug localization, patch drafting, and regression tests). I have reviewed the final diff line by line against the existing code paths — the single-boolean branch already rendered lowercase via |
What
Boolean where-filter lists were rendered into the aggregate GraphQL query with Python's
str(), emitting capitalizedTrue/False. Those are not valid GraphQL boolean literals, so a where filter containing a boolean list produced a query the server rejects at parse time.The single-boolean path already rendered correctly via
_bool_to_str()(true/false); only the list path was wrong — an asymmetry between the two branches.Reproduction
Building an aggregate query with a boolean list filter (reachable through the public
FilterDSL):Before:
{Aggregate{Question(where: {path: ["active"] operator: ContainsAny valueBoolean: [True,False]} ){meta{count}}}}(
[True,False]is invalid GraphQL — the server fails to parse the query.)After:
{Aggregate{Question(where: {path: ["active"] operator: ContainsAny valueBoolean: [true,false]} ){meta{count}}}}Root cause
In
Where.__str__(weaviate/gql/filter.py), the boolean branch used_render_list(self.value)for list values, which joins withstr(item).str(True)is"True". The non-list branch correctly used_bool_to_str. The fix maps_bool_to_strover each list element, matching the single-value branch.This affects
valueBooleanArray/valueBooleanList(e.g.Filter.by_property(...).contains_any([...])/contains_all([...])with booleans) in aggregate queries built byAggregateBuilder.Tests
Added
test/test_where_filter.py(pure unit tests, no live server):[true,false,true]and contains noTrue/False(regression — fails on the old code)Existing
test/collection/test_filter.pyandtest/test_util.pycontinue to pass.