Skip to content

Answer 413 for an oversized request body under Draft20260903 - #10440

Merged
glen-84 merged 2 commits into
mainfrom
gai/oversized-request-body-413
Sep 28, 2026
Merged

glen-84 merged 2 commits into
mainfrom
gai/oversized-request-body-413

Conversation

@glen-84

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

Copy link
Copy Markdown
Member

Summary

  • Under Draft20260903, a POST, persisted-operation POST, or QUERY request whose JSON body exceeds maxAllowedRequestSize answers 413, as the GraphQL over HTTP draft asks: "If the size of the POST request body was too large, status code 413 SHOULD be used." Legacy and Draft20250508 keep their answers, 200 for application/json under Legacy and 400 otherwise.
  • The size-limit error carries the HC0010 code under every transport version, because the parser now throws through ThrowHelper.DefaultHttpRequestParser_MaxRequestSizeExceeded. The message stays "Request size exceeds maximum allowed size.", so the helper's resource text was changed to it. The new code extension is worth a release-note line.
  • The middleware still proposes 400 and marks the result with an internal context-data key, which the default formatter maps to 413. A custom formatter that overrides OnDetermineStatusCode receives the same proposal as before.
  • Multipart requests are bounded by ASP.NET Core's FormOptions rather than maxAllowedRequestSize, and keep their current answer.
  • The HTTP transport, endpoints, and Fusion request-limits docs describe the new status and code.

Test plan

  • New theories in GraphQLOverHttpSpecTests pin the POST, persisted-operation POST, and QUERY answers per transport version against a server configured with AddGraphQLServer(maxAllowedRequestSize: 256), including the error body with HC0010.
  • HotChocolate.AspNetCore.Tests, HotChocolate.Language.Web.Tests, HotChocolate.Transport.Http.Tests, and HotChocolate.Fusion.AspNetCore.Tests pass on net10.0, and GraphQLOverHttpSpecTests passes on net8.0 and net11.0.

Copilot AI lite review requested due to automatic review settings September 28, 2026 08:46
@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

An unresolved moderate issue can return 200 for oversized requests accepting streaming formats, and two documentation qualifications are needed.

Review effort: Lite
Findings: 2 Low severity

Open (2)
What changed in this PR

Updates oversized JSON request handling to return 413 with HC0010 under Draft20260903, while preserving older transport behavior.

Changes:

  • Adds request-size classification and formatter status mapping.
  • Updates parser messaging and transport tests.
  • Documents revised HTTP and Fusion behavior.
File Summary
website/​content/​docs/​hotchocolate/​server/​http-transport.md Documents revised oversized-request status behavior.
website/​content/​docs/​hotchocolate/​server/​endpoints.md Documents HC0010 and 413; should qualify behavior to JSON request bodies.
website/​content/​docs/​fusion/​request-limits.md Documents Fusion request limits; should qualify behavior to JSON request bodies.
src/​HotChocolate/​AspNetCore/​test/​AspNetCore.Tests/​GraphQLOverHttpSpecTests.cs Adds transport-specific oversized-request coverage.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Utilities/​MiddlewareHelper.cs Marks oversized parser results for formatting.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Utilities/​HttpResultContextData.cs Adds oversized-request context metadata.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Properties/​AspNetCorePipelineResources.resx Updates the request-size error message.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Parsers/​DefaultHttpRequestParser.cs Produces the coded size-limit error.
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Formatters/​DefaultHttpResponseFormatter.cs Maps applicable oversized requests to 413; streaming formats currently bypass this conversion.

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

Comment thread website/content/docs/fusion/request-limits.md Outdated
Comment thread website/content/docs/hotchocolate/server/endpoints.md Outdated
@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (13/13)

File Covered Changed Patch %
…/Formatters/DefaultHttpResponseFormatter.cs 6 6 100.0% 🟢
…/src/AspNetCore.Pipeline/Parsers/DefaultHttpRequestParser.cs 1 1 100.0% 🟢
…/src/AspNetCore.Pipeline/Utilities/MiddlewareHelper.cs 6 6 100.0% 🟢

Project coverage: 58.8% (298858/508067 lines)

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