Skip to content

Auto-port 5.0: Use stream error for maxContentLength exceeded in InboundHttp2ToHttpAdapter#16628

Merged
chrisvest merged 1 commit into
5.0from
auto-port-pr-16558-to-5.0
Apr 15, 2026
Merged

Auto-port 5.0: Use stream error for maxContentLength exceeded in InboundHttp2ToHttpAdapter#16628
chrisvest merged 1 commit into
5.0from
auto-port-pr-16558-to-5.0

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #16558 to 5.0
Cherry-picked commit: d8dd805


Motivation:

When a message payload exceeds maxContentLength in InboundHttp2ToHttpAdapter, a connection error (INTERNAL_ERROR) is thrown. This sends a GOAWAY frame that closes the entire HTTP/2 connection, affecting all concurrent streams. Load balancers often treat GOAWAY as a 5xx error, even though this is a client-side issue (sending a payload that is too large). Exceeding the content length for a single stream should only affect that stream.

Modification:

Changed the error from connectionError(INTERNAL_ERROR) to streamError(streamId, ENHANCE_YOUR_CALM) in onDataRead(). The ENHANCE_YOUR_CALM error code is semantically appropriate for resource limit violations per RFC 7540 Section 7.

Added test exceedMaxContentLengthShouldCauseStreamErrorNotConnectionError() that sends oversized data on stream 3 and verifies:

  • A StreamException (not connection error) is produced
  • The error targets stream 3 with ENHANCE_YOUR_CALM error code
  • The test correctly fails when the fix is reverted

Result:

Fixes #11994.

…dapter (#16558)

Motivation:

When a message payload exceeds `maxContentLength` in
`InboundHttp2ToHttpAdapter`, a connection error (`INTERNAL_ERROR`) is
thrown. This sends a GOAWAY frame that closes the entire HTTP/2
connection, affecting all concurrent streams. Load balancers often treat
GOAWAY as a 5xx error, even though this is a client-side issue (sending
a payload that is too large). Exceeding the content length for a single
stream should only affect that stream.

Modification:

Changed the error from `connectionError(INTERNAL_ERROR)` to
`streamError(streamId, ENHANCE_YOUR_CALM)` in `onDataRead()`. The
`ENHANCE_YOUR_CALM` error code is semantically appropriate for resource
limit violations per RFC 7540 Section 7.

Added test
`exceedMaxContentLengthShouldCauseStreamErrorNotConnectionError()` that
sends oversized data on stream 3 and verifies:
- A `StreamException` (not connection error) is produced
- The error targets stream 3 with `ENHANCE_YOUR_CALM` error code
- The test correctly fails when the fix is reverted

Result:

Fixes #11994.

(cherry picked from commit d8dd805)
@chrisvest chrisvest added this to the 5.0.0.Final milestone Apr 10, 2026
@chrisvest chrisvest merged commit 5aa5d72 into 5.0 Apr 15, 2026
11 of 13 checks passed
@chrisvest chrisvest deleted the auto-port-pr-16558-to-5.0 branch April 15, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants