Repository navigation
Throw RequestError for scalar batch entries - #1993
Merged
Merged
Conversation
parseRequestParams() passed every batch entry to OperationParams::create(),
so bodies like ["x"] or {"query":"{ a }","0":"x"} threw a TypeError.
🤖 Generated with Claude Code
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Nested-array and null batch entries still bypass the new validation.
1 open finding
What changed in this PR
Improves malformed GraphQL batch-request handling by converting scalar-entry failures into RequestError.
Changes:
- Validates batch entries before creating operation parameters.
- Adds regression tests and changelog documentation.
| File | Description |
|---|---|
src/Server/Helper.php |
Adds batch-entry validation. |
tests/Server/RequestParsingTest.php |
Tests malformed batches and key-zero handling. |
CHANGELOG.md |
Documents the fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🤖 Generated with Claude Code
For {"query":"{ a }","0":"x"} the message pointed at the valid query
without saying which key it came from.
🤖 Generated with Claude Code
Array entries such as ["x"] still pass, since associative decoding makes them indistinguishable from objects. 🤖 Generated with Claude Code
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: c45b4bc | Previous: 6a7c89a | Ratio |
|---|---|---|---|
BuildSchemaBench::benchBuildSchema |
25.129 ms |
14.001 ms |
1.79 |
OverlappingFieldsCanBeMergedBench::benchRepeatedFields100 |
3.272 ms |
1.743 ms |
1.88 |
OverlappingFieldsCanBeMergedBench::benchRepeatedFields500 |
15.522 ms |
8.614 ms |
1.80 |
OverlappingFieldsCanBeMergedBench::benchRepeatedFields1000 |
31.437 ms |
16.946 ms |
1.86 |
OverlappingFieldsCanBeMergedBench::benchRepeatedFields2000 |
63.94 ms |
35.356 ms |
1.81 |
OverlappingFieldsCanBeMergedBench::benchRepeatedFields3000 |
95.805 ms |
52.179 ms |
1.84 |
VisitorBench::benchVisitIntrospectionWithEnterLeave |
0.304 ms |
0.159 ms |
1.91 |
VisitorBench::benchVisitIntrospectionWithKindMap |
0.3 ms |
0.154 ms |
1.95 |
VisitorBench::benchVisitIntrospectionWithKindCallable |
0.277 ms |
0.143 ms |
1.94 |
VisitorBench::benchVisitIntrospectionWithEnterLeaveMap |
0.304 ms |
0.16 ms |
1.90 |
VisitorBench::benchVisitNestedWithEnterLeave |
0.07 ms |
0.036 ms |
1.94 |
ScalarOverrideBench::benchExecuteWithoutOverride |
0.162 ms |
0.081 ms |
2 |
ScalarOverrideBench::benchExecuteWithTypesOverride |
0.164 ms |
0.081 ms |
2.02 |
StarWarsBench::benchSchema |
0.005 ms |
0.003 ms |
1.67 |
StarWarsBench::benchHeroQuery |
0.328 ms |
0.178 ms |
1.84 |
StarWarsBench::benchNestedQuery |
0.719 ms |
0.396 ms |
1.82 |
StarWarsBench::benchQueryWithFragment |
0.766 ms |
0.425 ms |
1.80 |
StarWarsBench::benchQueryWithInterfaceFragment |
0.718 ms |
0.391 ms |
1.84 |
StarWarsBench::benchStarWarsIntrospectionQuery |
7.223 ms |
3.954 ms |
1.83 |
HugeSchemaBench::benchSchema |
12.919 ms |
7.536 ms |
1.71 |
HugeSchemaBench::benchSmallQuery |
15.148 ms |
8.289 ms |
1.83 |
HugeSchemaBench::benchSmallQueryLazy |
16.741 ms |
9.704 ms |
1.73 |
LexerBench::benchIntrospectionQuery |
0.299 ms |
0.162 ms |
1.85 |
LexerBench::benchDeeplyIndentedQuery |
1.933 ms |
1.054 ms |
1.83 |
DeferredBench::benchSingleDeferred |
0.001 ms |
0 ms |
+∞ |
DeferredBench::benchNestedDeferred |
0.003 ms |
0.001 ms |
3 |
DeferredBench::benchChain5 |
0.005 ms |
0.003 ms |
1.67 |
DeferredBench::benchChain100 |
0.082 ms |
0.044 ms |
1.86 |
DeferredBench::benchManyDeferreds |
0.45 ms |
0.225 ms |
2 |
DeferredBench::benchManyNestedDeferreds |
14.384 ms |
6.324 ms |
2.27 |
DeferredBench::bench1000Chains |
3.56 ms |
1.766 ms |
2.02 |
This comment was automatically generated by workflow using github-action-benchmark.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Malformed batch bodies such as
["x"]caused an uncaughtTypeErrorinstead of aRequestError.Helper::parseRequestParams()now rejects scalar batch entries.An object with a non-null key `0` still counts as a batch, so the message names the offending key
{"query":"{ a }","0":"x"}fails withExpected batch entry query to be an object, got: "{ a }".Batch detection stays
isset($bodyParams[0]), so{"0":null,"query":"{ a }"}is still a single operation.No other server checked has a dedicated message for this case: JS servers detect batches with
Array.isArray, and laragraph/utils#27 also uses a generic message.The fix targets master only, not 14.x
14.x has the same bug, but its last release was https://github.com/webonyx/graphql-php/releases/tag/v14.11.10 in 2023.
🤖 Generated with Claude Code