Repository navigation
fix(validator): refuse filter values that are not a list - #1028
Merged
Merged
Conversation
A query parsed from JSON takes an object for its values as readily as a list. Filter read such values by position, so isEmpty() raised "Undefined array key 0" for an equal, contains, exists or spatial query, and a distance tuple given as an object raised the same for its distance. A vector query on an undeclared attribute of a schemaless collection read the schema by its name and warned too. 7.4.2 reads the values the same way. Filter refuses values that are not a list, and a distance tuple that is not a list of geometry, finite distance and boolean meters flag, which the builder's typed distance filter would otherwise reject with a TypeError. A vector value has to be a list as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…apter Covers find() and count() on each adapter for the values QA sent as a JSON object, including spatial and vector filters where the adapter has them, and fails on main with the "Undefined array key 0" warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 30 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Staging log scan found a PHP warning,
Undefined array key 0atValidator/Query/Filter.php:436(isEmpty()), on list endpoints when a query'svaluesarrive as a JSON object ({"a":1}) instead of a list.Query::parse()accepts an object forvaluesas readily as a list.Filterread the values by position, which raised the warning. In the library such a filter was then accepted:find()on main returns rows for{"method":"equal","attribute":"name","values":{"value":"a"}}on every adapter, and MongoDB raises a second warning inMongo.php. A distance tuple given as an object warned the same way, and a vector query on an undeclared attribute of a schemaless collection read the schema by name and warned.Filternow refuses:<Method> query values must be a list;[geometry, finite distance, boolean meters]. Without this, the builder's typed distance filter would reject it with aTypeError;This is ported from the unpushed
qfix-overflowwork (214f0fe0f), with an E2E test on every adapter added.Regression tests
DocumentTests::testFilterValuesThatAreNotAListAreAnInvalidQuery: equal (string and numeric keys), notEqual, contains, lessThan, between, startsWith, exists; intersects, distanceLessThan (tuple as object, and geometry as object) where spatial; vectorDot where vectors; each onfind()andcount(); a list-valued equal still matchesfind() refuses {"method":"equal",...,"values":{"value":"a"}}(accepted) plus PHP warningUndefined array key 0atFilter.php:436Mongo.php:3560Unit\Validator\Query\FilterMalformedValuesTest(9 object-valued methods, distance tuple as object, schemaless vector)Run locally against Docker: the full adapter suites for MySQL, MariaDB, Postgres, SQLite, MongoDB, Memory and Redis pass, as do the full unit suite, Pint and PHPStan.
API repro (Appwrite)
GET /v1/tablesdb/{db}/tables/{t}/rows?queries[]={"method":"equal","attribute":"name","values":{"a":1}}→400 general_query_invalid, messageInvalid query: Equal query values must be a list, and no PHP warning in the logs. The same applies toqueries[]={"method":"distanceLessThan","attribute":"pt","values":{"geometry":[[1,2],10,false]}}.The spatial range PR is stacked on this one; merge this first.
🤖 Generated with Claude Code