feat: Add requestComplexity.subqueryLimit option to limit subquery results#10420
Conversation
|
🚀 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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant API as Parse Server API
participant RestQ as RestQuery.replaceX
participant SubQ as Subquery Executor
participant DB as Database
Client->>API: request with $inQuery/$select/etc.
API->>RestQ: build/replace subquery clause
RestQ->>RestQ: read config.requestComplexity.subqueryLimit
RestQ->>SubQ: execute subquery (with additionalOptions.limit = subqueryLimit)
SubQ->>DB: run limited query
DB-->>SubQ: limited result set
SubQ-->>RestQ: results -> transform to $in/$nin pointers
RestQ-->>API: finalized query
API-->>Client: response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
spec/RequestComplexity.spec.js (1)
807-829: Consider adding maintenance-key bypass coverage as well.You already validate master bypass; adding one maintenance-key assertion here would keep parity with other request-complexity suites and guard privileged-path regressions.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@spec/RequestComplexity.spec.js` around lines 807 - 829, Add a test that mirrors the master-key bypass case but uses the maintenance key: create an it block like "should allow unlimited subquery results with maintenance key" that builds the same where ($inQuery against 'Target'), calls rest.find(config, auth.maintenance(config), 'Source', where) and asserts result.results.length === totalObjects; place it alongside the existing master-key test to provide parity and protect privileged-path regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/RestQuery.js`:
- Around line 566-571: The guard checking rc.subqueryLimit > 0 incorrectly
treats 0 as "no limit"; update the checks in the four subquery replacement
methods (replaceInQuery, replaceNotInQuery, replaceSelect, replaceDontSelect) to
apply the limit whenever rc.subqueryLimit !== -1 (i.e., only treat -1 as
disabled) and set additionalOptions.limit = rc.subqueryLimit as before; also add
a regression test verifying that subqueryLimit: 0 enforces a zero limit behavior
(and that -1 disables it).
---
Nitpick comments:
In `@spec/RequestComplexity.spec.js`:
- Around line 807-829: Add a test that mirrors the master-key bypass case but
uses the maintenance key: create an it block like "should allow unlimited
subquery results with maintenance key" that builds the same where ($inQuery
against 'Target'), calls rest.find(config, auth.maintenance(config), 'Source',
where) and asserts result.results.length === totalObjects; place it alongside
the existing master-key test to provide parity and protect privileged-path
regressions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a0a8c252-df0a-4cf3-8110-7d953fd29de7
📒 Files selected for processing (5)
spec/RequestComplexity.spec.jssrc/Options/Definitions.jssrc/Options/docs.jssrc/Options/index.jssrc/RestQuery.js
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10420 +/- ##
==========================================
- Coverage 92.50% 92.49% -0.01%
==========================================
Files 192 192
Lines 16770 16786 +16
Branches 234 234
==========================================
+ Hits 15513 15527 +14
- Misses 1234 1236 +2
Partials 23 23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review your feedback conversations and resolve where you found a consensus |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 26751 🏁 Script executed: Length of output: 240 🏁 Script executed: Length of output: 92
🧠 Learnings used |
# [9.8.0-alpha.12](9.8.0-alpha.11...9.8.0-alpha.12) (2026-04-10) ### Features * Add `requestComplexity.subqueryLimit` option to limit subquery results ([#10420](#10420)) ([bf40004](bf40004))
|
🎉 This change has been released in version 9.8.0-alpha.12 |
Issue
Subquery operators (
$inQuery,$notInQuery,$select,$dontSelect) run internal subqueries without any result limit, allowing unbounded memory growthTasks