Skip to content

fix(graphql): keep nested payload data past the escaping depth limit - #13533

Merged
HarshMN2345 merged 7 commits into
mainfrom
fix/graphql-escape-payload-depth
Sep 8, 2026
Merged

HarshMN2345 merged 7 commits into
mainfrom
fix/graphql-escape-payload-depth

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Closes #11897

What does this PR do?

Preserves nested GraphQL response data beyond the escaping depth limit instead of replacing it with null. It also recurses before renaming array-valued $ keys, preventing the original keys from being recreated alongside the escaped keys. This keeps raw $permissions out of GraphQL row data while preserving _permissions.

Test Plan

  • Extends UsersTest::testGetUsers to check that the listed user's nested email target survives.
  • Extends TablesDB/DatabaseServerTest::testGetRow to check _permissions and reject duplicated $permissions inside data.

Both focused E2E tests fail against the original resolver and pass with the fix (21 and 47 assertions). Pint, PHP syntax checks, and the focused Rector dry run pass.

escapePayload() returned null once the depth guard tripped, and the caller
assigns that result straight back into the parent array, so every value below
_APP_GRAPHQL_MAX_DEPTH was replaced with null instead of merely being left
unescaped. Return the payload untouched instead.

Escaping also ran before the recursion, so an array held under a $-prefixed
key was written unrecursed to the escaped key and then restored under the
original key by the recursion step, leaving both keys in the payload. Recurse
first, then escape, so each key is written once.
@greptile-apps

greptile-apps Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects GraphQL payload escaping so data beyond the configured recursion limit is preserved and array-valued $ keys are not recreated after being renamed.

  • Returns the untouched nested payload once the escaping depth limit is exceeded.
  • Recurses into array values before renaming $-prefixed keys.
  • Extends user-list coverage for deeply nested target data.
  • Extends TablesDB row coverage for escaped permissions without duplicate raw keys.

Confidence Score: 5/5

The PR appears safe to merge, with the prior test-isolation finding resolved and no new actionable defects identified.

The resolver now returns nested payload data unchanged beyond the configured depth and performs recursion before renaming array-valued system keys. The remaining E2E assertions cover both corrected behaviors, and the previously state-dependent users test now creates and filters for its own user.

Important Files Changed

Filename Overview
src/Appwrite/GraphQL/Resolvers.php Preserves payloads beyond the escape depth limit and safely renames array-valued system keys after recursion.
tests/e2e/Services/GraphQL/Base.php Expands the users-list query to retrieve nested target fields needed for regression coverage.
tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php Verifies row permissions remain available under the escaped key and are absent from serialized row data under the raw key.
tests/e2e/Services/GraphQL/UsersTest.php Makes the users-list regression test self-contained and verifies nested email target data survives payload escaping.

Reviews (7): Last reviewed commit: "test(graphql): keep payload regressions ..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/graphql-escape-payload-depth (after).

Metric Before After Change
🚀 Requests/sec 173.7 171.19 ⚪ -1.4%
⏱️ Latency P50 97.47 ms 98.65 ms ⚪ +1.2%
⏱️ Latency P95 243.35 ms 243.03 ms ⚪ -0.1%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 98.65 243.03 10,887 171.19 -0.32
Account 204.61 380.79 573 9.47 -12.4
TablesDB 94.13 176.22 5,921 96.09 +8.37
Storage 93.15 200.95 2,865 48.14 +4.43
Functions 154.69 306.15 1,528 26.26 +4.24

Top API waits (after)

API request Max wait (ms)
account.name.update 585.05
account.prefs.update 558.51
functions.variables.update 452.63
tablesdb.rows.decrement 420.42
tablesdb.rows.create 417.86

@HarshMN2345
HarshMN2345 merged commit 857698d into main Sep 8, 2026
45 of 46 checks passed
@ChiragAgg5k ChiragAgg5k mentioned this pull request Sep 10, 2026
2 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

escapePayload returns null at max depth causing data loss in GraphQL responses

2 participants