Title: Limit input-value depth in variables and schema defaults by andimarek · Pull Request #4552 · graphql-java/graphql-java · GitHub
Open Graph Title: Limit input-value depth in variables and schema defaults by andimarek · Pull Request #4552 · graphql-java/graphql-java
X Title: Limit input-value depth in variables and schema defaults by andimarek · Pull Request #4552 · graphql-java/graphql-java
Description: Deeply nested external variables can overflow recursive coercion even for a small operation. This change adds InputValueLimits, with a default maximum depth of 128 input-object/list values per path. The policy applies at two boundaries: Supplied variable values are checked during coercion and normalized-variable conversion, using the request's GraphQLContext override or the JVM-wide limit. Exceeding the limit produces the existing variable-coercion request error, including the variable definition location. Schema defaults are checked during schema validation using the JVM-wide limit, consistently for SDL literals, programmatic values, and legacy internal defaults. Each default is checked independently before recursive schema validators inspect it. Request overrides and later global changes do not recheck validated defaults during execution, getters, printing, or introspection. Non-null wrappers do not count. Nulls and scalar payloads are not traversed. Singleton-list coercion counts as a list level, and siblings do not accumulate depth. Filling in an omitted schema default does not consume the supplied variable's depth budget. The early schema check reports the default's coordinate without printing the oversized value. Programmatic list defaults use collections or arrays; iterators, streams, and other iterables are rejected during schema validation without being consumed. Applications can configure InputValueLimits.newInputValueLimits().maxDepth(...), use InputValueLimits.NONE for trusted inputs, or change the JVM-wide limit with setDefaultLimits. Set the JVM-wide limit before building a schema to control default validation; per-request overrides govern supplied variables only. Breaking change: Values deeper than 128 are rejected by default, including schema defaults at build time. Programmatic list defaults must use collections or arrays. Custom scalar payloads remain the scalar implementation's responsibility. Internal coercion helpers no longer carry synthetic variable names. Variable names are attached to request errors at the variable boundary; internal OneOf assertions identify the input type. Tests exercise exact boundaries across argument, input-field and directive defaults; SDL parsing; strict request overrides; introspection and default getters; supplied-variable rejection; very deep and cyclic defaults; list coercion; scalar opacity; and rejecting one-shot inputs without consuming them. Validation: Full local Java 25 validation passed: ./gradlew test testng check javadoc jacocoTestReport. Spock: 6,292 passed, 7 skipped. TestNG: 141 passed, 49 skipped. No per-class coverage regressions across 995 classes against the unchanged baseline. 36 limit/default tests passed with -Xss256k; the final cyclic-default case also passed in the full suite. The diagnostic cleanup passed 247 existing tests locally (1 skipped) and build checks, without adding test cases. All 10 GitHub checks passed on ad9cce96f: Java 17/21/25 tests and TestNG, build checks, Javadoc, jcstress, file validation, and the per-class coverage gate. JMH results recorded for the initial variable-coercion commit 9afd53208 used two forks, three 5-second warmup iterations, and three 5-second measurement iterations per fork (µs/op, master → initial implementation): scalar 0.045 → 0.045; shallow object 0.078 → 0.075; 100-item list 0.776 → 0.794; 33-level object chain 11.257 → 11.462. The small differences were within the measured uncertainty. These measurements do not cover the added schema-validation pass; no new timing claim is made for the follow-up. HTTP adapters may enforce JSON nesting limits before values reach GraphQL Java; this change also protects direct ExecutionInput callers.
Open Graph Description: Deeply nested external variables can overflow recursive coercion even for a small operation. This change adds InputValueLimits, with a default maximum depth of 128 input-object/list values per path...
X Description: Deeply nested external variables can overflow recursive coercion even for a small operation. This change adds InputValueLimits, with a default maximum depth of 128 input-object/list values per path...
Opengraph URL: https://github.com/graphql-java/graphql-java/pull/4552
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3a61575e-7fe8-25f3-3ec2-e5e9cb57f891 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B3E8:785A9:24DDC43:2EC1DF1:6B0188E0 |
| html-safe-nonce | 356e2e66a6fa27418e79e88df8162eb4a7e1f14d3263553851b61d9069339cc5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0U4Ojc4NUE5OjI0RERDNDM6MkVDMURGMTo2QjAxODhFMCIsInZpc2l0b3JfaWQiOiIyODExMjEyNTc5ODY1NzI1MTUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 15a478aad51b7af13acddcba8b390ef1fd840510b5723f20417af50ef3bfad24 |
| hovercard-subject-tag | pull_request:5268024408 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/graphql-java/graphql-java/pull/4552/files |
| twitter:image | https://avatars.githubusercontent.com/u/1706744?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1706744?s=400&v=4 |
| og:image:alt | Deeply nested external variables can overflow recursive coercion even for a small operation. This change adds InputValueLimits, with a default maximum depth of 128 input-object/list values per path... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width