Skip to content

[Fusion] Fix an empty variable batch answering 500 instead of 400 or 422 - #10433

Merged
glen-84 merged 1 commit into
mainfrom
gai/fusion-empty-variable-batch-error
Sep 25, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/fusion-empty-variable-batch-error

Conversation

@glen-84

@glen-84 glen-84 commented Sep 25, 2026

Copy link
Copy Markdown
Member

Summary

  • With cost analysis skipped, the Fusion gateway answered a variable batch with an empty variables array with 500 "Unexpected Execution Error", because execution read the first variable set. It now answers the request error Core returns since Fix missing pipeline state answering 400 or 422 instead of 500 #10430, "A variable batch request must contain at least one variable set.", which is 400 under Draft20250508 and 422 under Draft20260903. With cost analysis on, the analyzer still rejects the empty batch first.
  • The guard fires only when no variable set was coerced and the request's array is empty. An empty batch for an operation that declares no variables still executes once, and a batch that reaches execution without its coerced sets still answers 500.
  • A new Core test pins the case of an operation without variables, so Core and Fusion both cover it.

Test plan

  • VariableBatchingTests in Fusion.AspNetCore.Tests pins three answers over HTTP: the request error under both transport versions, a single execution for an operation that declares no variables, and 500 for a batch that reaches execution without coerced sets. Removing either guard condition fails exactly the test that pins it.
  • GraphQLOverHttpSpecTests.Post_Should_ExecuteOnce_When_VariableBatchIsEmptyAndNoVariableIsDeclared pins Core's answer for an operation that declares no variables.
  • Fusion.AspNetCore.Tests, Fusion.Execution.Tests, and GraphQLOverHttpSpecTests pass.

Copilot AI lite review requested due to automatic review settings September 25, 2026 09:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

All reviewed changes are covered by regression tests and no unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Fixes Fusion handling of empty variable batches by returning the appropriate 400/422 request error instead of a 500, while preserving execution for operations without declared variables.

Changes:

  • Added an empty-batch execution guard and localized error message.
  • Added Fusion and Core regression coverage.
  • Preserved 500 behavior for unexpectedly missing coerced variables.
File Description
src/​HotChocolate/​Fusion/​test/​Fusion.AspNetCore.Tests/​VariableBatchingTests.cs Adds Fusion HTTP regression tests.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Properties/​FusionExecutionResources.resx Adds the request error message.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Properties/​FusionExecutionResources.Designer.cs Exposes the localized resource.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Execution/​Pipeline/​OperationExecutionMiddleware.cs Detects empty variable batches.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Execution/​ErrorHelper.cs Creates the request error result.
src/​HotChocolate/​AspNetCore/​test/​AspNetCore.Tests/​GraphQLOverHttpSpecTests.cs Verifies Core behavior for variable-free operations.
Files not reviewed (1)
  • src/HotChocolate/Fusion/src/Fusion.Execution/Properties/FusionExecutionResources.Designer.cs: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (10/10)

File Covered Changed Patch %
…/Fusion/src/Fusion.Execution/Execution/ErrorHelper.cs 4 4 100.0% 🟢
…/Execution/Pipeline/OperationExecutionMiddleware.cs 6 6 100.0% 🟢

Project coverage: 58.9% (300480/510416 lines)

@glen-84
glen-84 merged commit 59e0de0 into main Sep 25, 2026
306 of 308 checks passed
@glen-84
glen-84 deleted the gai/fusion-empty-variable-batch-error branch September 25, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants