Repository navigation
fix(graphql): cost invalid list limits at the complexity cap - #14821
Conversation
The complexity callback multiplied by the raw limit, so a limit below 1 could cancel out its siblings before the query validator rejected it.
|
Review complete. No issues found — approved ✅. This PR fixes a GraphQL query-complexity scoring edge case where a list field's limit multiplied by its base complexity could overflow or otherwise bypass the cap, and adds an e2e regression test. The complexity closure now clamps results to
Reviewed commit: 49065fc |
🟢 Tier S · Ready to merge
The GraphQL list-field complexity callback now assigns invalid list limits an over-cap cost and caps individual contributions, preventing invalid limits from reducing aggregate cost or overflowing it. E2E coverage checks that valid limits pass and negative, over-cap, and PHP_INT_MAX limits are rejected when abuse-enabled complexity rules are active. Latest changes: The new commits move the complexity regression test from the GraphQL users suite into AbuseTest under the abuseEnabled group and assert the HTTP status for each rejected operation.
📂 Walkthrough · 3
Merged |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
The complexity rule is only registered when abuse options are enabled, so the test has to live in the abuseEnabled group.
…y-limit # Conflicts: # tests/e2e/General/AbuseTest.php
…y-limit fix(graphql): cost invalid list limits at the complexity cap (cherry picked from commit 70b1d4c)
What
The GraphQL complexity callback for list fields multiplied the child complexity by the
limitquery as given. A limit below 1 is rejected later by the route's query validator, but by then the complexity check has already summed it, so it could lower the operation's total cost.The callback now treats a missing, non-integer, below-1 or above-the-cap limit as just over
_APP_GRAPHQL_MAX_COMPLEXITYand caps each field's cost there, which also keeps the sum an integer for very large limits (webonyx's complexity rule returnsint). Valid limits are costed exactly as before.Tests
General\AbuseTest::testGraphQLComplexityIgnoresInvalidLimits(abuseEnabled group, since the complexity rule is only registered with abuse options on): two aliasedusersListfields withlimit(10)succeed;limit(100)next to a field with a negative limit, and aPHP_INT_MAXlimit, are each refused with the max complexity error and no data. Runs on CI.Related: appwrite-labs/cloud#6666