Repository navigation
fix: Malformed query operators $or, $and, $nor, $options cause internal server error - #10775
Conversation
…e internal server error
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10775 +/- ##
==========================================
+ Coverage 93.99% 94.01% +0.01%
==========================================
Files 193 193
Lines 17126 17149 +23
Branches 259 259
==========================================
+ Hits 16098 16123 +25
+ Misses 1006 1004 -2
Partials 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
## [9.10.5-alpha.3](9.10.5-alpha.2...9.10.5-alpha.3) (2026-10-10) ### Bug Fixes * Malformed query operators `$or`, `$and`, `$nor`, `$options` cause internal server error ([#10775](#10775)) ([c56ccdf](c56ccdf))
|
🎉 This change has been released in version 9.10.5-alpha.3 |
Pull Request
Issue
Closes: #10762
Approach
Malformed logical operators and
$optionswithout$regexare now rejected withINVALID_QUERY(102) and a descriptive message before any code walks the query. The response is the same for every auth level and on both databases.validateQueryFormatruns as the first step ofRestQuery.buildRestWhere, so it also covers count, subqueries, includes and where clauses set bybeforeFindtriggers.$or,$andand$normust be non-empty arrays of objects, and$optionsmust be used with$regex.validateQuerynow also rejects falsy and empty$or/$andvalues for queries passed to the database controller directly.RestQuerykeeps its condition, but no longer replaces its error with "Permission denied".Bad $or format - use an array of at least 1 value.,Bad $or format - use an array of objects.(the same for$andand$nor), and$options requires $regex.Notes:
$or: [[], {...}]) is still accepted, because the PHP SDK sends[]for a query without constraints.$or: [1]used to be ignored on MongoDB, which returned all objects; they are now rejected.$or: [{}]and drops{}elements inside$or/$nor. That is a separate adapter bug, so the tests for those shapes run on MongoDB only.Tasks
Summary by CodeRabbit
$and,$or, or$nornow receive anINVALID_QUERYerror with a format-specific message.$optionswithout$regexare now rejected as invalid.$regexqueries with$optionscontinue to be accepted.