Skip to content

Fix variable batches over WebSocket completing without results - #10825

Merged
glen-84 merged 2 commits into
mainfrom
gai/websocket-variable-batch-error
Nov 9, 2026
Merged

glen-84 merged 2 commits into
mainfrom
gai/websocket-variable-batch-error

Conversation

@glen-84

@glen-84 glen-84 commented Nov 9, 2026

Copy link
Copy Markdown
Member

Summary

  • A request whose variables is a list, sent over WebSocket, completed without delivering any results. Both protocol handlers, graphql-transport-ws and graphql-ws, now answer it with an error message for the operation: "Variable batching is not supported for WebSocket requests." (HC0009).
  • Over graphql-transport-ws this also applies to each entry of a request batch. The connection stays open.

Test plan

  • New tests in each protocol's WebSocketProtocolTests send a variable batch, and over graphql-transport-ws also a request batch with a variable batch entry, and expect the error message. They fail on main, where the client receives complete or no message.
  • Ran on net10.0: the HotChocolate.AspNetCore.Subscriptions tests in HotChocolate.AspNetCore.Tests, GatewayBuilderInterceptorTests in HotChocolate.Fusion.AspNetCore.Tests, and the WebSocket tests in HotChocolate.Fusion.Diagnostics.Tests.

Copilot AI lite review requested due to automatic review settings November 9, 2026 13:10

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.

🟢 Approval recommended

No unresolved review issues are identified for the WebSocket variable-batching error-handling changes.

No open issues 🎉

1 file not reviewed
  • src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.Designer.cs: Generated file
What changed in this PR

This pull request fixes variable-batched GraphQL requests over WebSocket by returning an HC0009 operation error instead of completing without results. The connection remains available for subsequent messages.

Changes:

  • Reject variable batching in both supported WebSocket protocols.
  • Validate each entry in graphql-transport-ws request batches.
  • Add centralized error resources and protocol integration tests.
  • Update tests to verify that the connection remains open after an error.
  • Route new exception paths through the established ThrowHelper convention.
File Summary
src/​HotChocolate/​AspNetCore/​test/​AspNetCore.Tests/​Subscriptions/​GraphQLOverWebSocket/​WebSocketProtocolTests.cs Tests variable-batch rejection, including request-batch entries. The test should also verify that the connection remains usable after the error.
src/​HotChocolate/​AspNetCore/​test/​AspNetCore.Tests/​Subscriptions/​Apollo/​WebSocketProtocolTests.cs Tests the Apollo protocol error response. The test should also verify that the connection remains usable after the error.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Utilities/​ErrorHelper.cs Adds the centralized HC0009 variable-batching WebSocket error.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Subscriptions/​Protocols/​GraphQLOverWebSocket/​GraphQLOverWebSocketProtocolHandler.cs Rejects variable-batched requests for graphql-transport-ws; the new exception path should use a ThrowHelper factory.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Subscriptions/​Protocols/​Apollo/​ApolloSubscriptionProtocolHandler.cs Rejects variable-batched requests for the Apollo protocol; the new exception path should use a ThrowHelper factory.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Properties/​AspNetCorePipelineResources.resx Defines the localized WebSocket variable-batching error message.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Properties/​AspNetCorePipelineResources.Designer.cs Exposes the generated resource accessor.

Review effort: Lite

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (17/17)

File Covered Changed Patch %
…/Protocols/Apollo/ApolloSubscriptionProtocolHandler.cs 6 6 100.0% 🟢
…/GraphQLOverWebSocket/GraphQLOverWebSocketProtocolHandler.cs 7 7 100.0% 🟢
…/AspNetCore/src/AspNetCore.Pipeline/Utilities/ErrorHelper.cs 4 4 100.0% 🟢

Project coverage: 59.5% (321536/540819 lines)

@glen-84
glen-84 merged commit 1a8b3be into main Nov 9, 2026
157 checks passed
@glen-84
glen-84 deleted the gai/websocket-variable-batch-error branch November 9, 2026 17:10
glen-84 added a commit that referenced this pull request Nov 9, 2026
glen-84 added a commit that referenced this pull request Nov 9, 2026
glen-84 added a commit that referenced this pull request Nov 10, 2026
This was referenced Nov 10, 2026
This was referenced Nov 19, 2026
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