Skip to content

Refuse an empty variable batch in the HTTP transport - #10441

Merged
glen-84 merged 3 commits into
mainfrom
gai/refuse-empty-variable-batches
Sep 28, 2026
Merged

glen-84 merged 3 commits into
mainfrom
gai/refuse-empty-variable-batches

Conversation

@glen-84

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

Copy link
Copy Markdown
Member

Summary

  • The HTTP transport refuses a request whose variables field is an empty array before any interceptor or execution runs, whether or not the operation declares variables. It answers like an empty request batch: 400 under Draft20250508 and 422 under Draft20260903, with "A variable batch request must contain at least one variable set." and HC0009. An operation that declares no variables previously executed once. "variables": null, "variables": {}, and an omitted variables stay single requests.
  • The check runs in every ExecutorSession parse method, so POST, GET, multipart, HTTP QUERY, request batches, and the persisted-operation routes all refuse it, and a request batch with one such entry is refused as a whole. WebSocket subscriptions do not use these methods.
  • The execution guards from Fix missing pipeline state answering 400 or 422 instead of 500 #10430 and [Fusion] Fix an empty variable batch answering 500 instead of 400 or 422 #10433 stay for in-process execution, and their tests move in-process. The batching page, the Fusion cost analysis page, and the 16.6 to 16.7 migration guide describe the new answer.

Test plan

  • GraphQLOverHttpSpecTests pins the POST answer for operations with and without declared variables under both transport versions, the GET answer, and the refused request batch. VariableBatchingTests pins the same answers for the Fusion gateway.
  • OperationExecutionMiddlewareTests in Execution.Tests and Fusion.Execution.Tests pins each execution guard; removing either guard fails its test.
  • AspNetCore.Tests and Fusion.AspNetCore.Tests pass in full.

Copilot AI lite review requested due to automatic review settings September 28, 2026 10:05
@github-actions github-actions Bot added 📚 documentation This issue is about working on our documentation. 🌶️ hot chocolate labels Sep 28, 2026

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

🟡 Changes recommended

A critical resource-leak issue remains, along with missing persisted-operation and multipart regression coverage.

Review effort: Lite
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

This pull request rejects empty HTTP variable batches before execution, preserves in-process guards, and updates related tests and documentation.

Changes:

  • Validates variables: [] across HTTP parsing paths.
  • Adds Core, Fusion, and transport regression coverage.
  • Documents status-code and migration behavior.
File Reviewed changes
website/​content/​docs/​hotchocolate/​server/​batching.md Documents empty-batch rejection; legacy JSON status wording needs qualification.
website/​content/​docs/​hotchocolate/​migrating/​migrate-from-16-6-to-16-7.md Documents migration behavior; should mention the legacy JSON 200 response.
website/​content/​docs/​fusion/​cost-analysis.md Updates cost-analysis context.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​Execution/​Pipeline/​OperationExecutionMiddlewareTests.cs Covers Fusion execution guards.
src/​HotChocolate/​Fusion/​test/​Fusion.AspNetCore.Tests/​VariableBatchingTests.cs Covers Fusion HTTP variable batching.
src/​HotChocolate/​Fusion/​test/​Fusion.AspNetCore.Tests/​CostReportingTests.cs Updates cost-reporting coverage.
src/​HotChocolate/​Core/​test/​Execution.Tests/​Pipeline/​OperationExecutionMiddlewareTests.cs Covers Core execution guards.
src/​HotChocolate/​AspNetCore/​test/​AspNetCore.Tests/​GraphQLOverHttpSpecTests.cs Covers POST, GET, and request batches; one test name needs correction.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Utilities/​ErrorHelper.cs Adds the request error helper.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Properties/​AspNetCorePipelineResources.resx Adds localized error text.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Properties/​AspNetCorePipelineResources.Designer.cs Adds the generated resource accessor.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​ExecutorSession.cs Adds parsing validation; disposal handling and persisted/multipart coverage require changes.
Files not reviewed (1)
  • src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.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

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (53/53)

File Covered Changed Patch %
…/AspNetCore/src/AspNetCore.Pipeline/ExecutorSession.cs 47 47 100.0% 🟢
…/AspNetCore/src/AspNetCore.Pipeline/Utilities/ErrorHelper.cs 6 6 100.0% 🟢

Project coverage: 58.8% (298926/508115 lines)

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

🔵 Needs a closer look

Add HTTP QUERY coverage and Legacy application/json coverage for empty variable batches.

Review effort: Lite
Findings: None

Resolved since last review (2)
Files not reviewed (1)
  • src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.Designer.cs: Generated file

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

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

Files not reviewed (1)
  • src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.Designer.cs: Generated file

This was referenced Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation. 🌶️ hot chocolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants