Skip to content

fix: retain SETTINGS and HPACK error codes - #1000

Closed
cristi- wants to merge 1 commit into
hyperium:masterfrom
cristi-:cc/h2-error-codes
Closed

cristi- wants to merge 1 commit into
hyperium:masterfrom
cristi-:cc/h2-error-codes

Conversation

@cristi-

@cristi- cristi- commented Nov 5, 2026

Copy link
Copy Markdown
  1. Problem: Malformed SETTINGS payload lengths are reported as PROTOCOL_ERROR instead of the required FRAME_SIZE_ERROR.
    Fix: Preserve the specific size-error classification when loading SETTINGS.
    Example: A three-byte SETTINGS payload, or an ACK carrying a payload, now yields error code 6 instead of 1.
    Impact: RFC 9113-compliant error reporting.
    Existing client impact: These invalid frames already close the connection; only the error code changes. Valid SETTINGS and semantic validation are unchanged.

  2. Problem: Invalid HPACK blocks are reported as PROTOCOL_ERROR instead of COMPRESSION_ERROR.
    Fix: Map HPACK decoder failures to COMPRESSION_ERROR, including truncated final blocks and CONTINUATION frames.
    Example: Indexed header field 0 (0x80) now yields error code 9 instead of 1.
    Impact: Correct connection-error classification for compression failures.
    Existing client impact: Valid header blocks, stream-level semantic errors, incomplete nonfinal blocks, and abuse limits retain their behavior.

Validation: one raw-wire regression covers both SETTINGS cases, invalid/truncated HPACK, and CONTINUATION. It passes on the fix and fails immediately on the unmodified master source. Tested remotely with cargo +nightly test --locked -p h2-tests --test codec_read malformed_settings_and_hpack_preserve_error_codes.

Reference: https://www.rfc-editor.org/rfc/rfc9113.html (sections 6.5 and 4.3).

Problem: SETTINGS payload-size failures and HPACK decoder failures are collapsed into PROTOCOL_ERROR.

Solution: preserve FRAME_SIZE_ERROR for SETTINGS size violations and COMPRESSION_ERROR for HPACK failures, including final truncated blocks and continuations. Keep existing semantic header errors and abuse limits unchanged.

Validation: the raw-wire regression passes on the fix and fails on the original source. Covers malformed SETTINGS, nonempty ACK, bad HPACK indices, truncated HPACK, and CONTINUATION.

Co-authored-by: Codex GPT-6.1 Sol <[email protected]>
@seanmonstar

Copy link
Copy Markdown
Member

This is on purpose. Note what the RFC says:

Additionally, an endpoint MAY use any applicable error code when it detects an error condition; a generic error code (such as PROTOCOL_ERROR or INTERNAL_ERROR) can always be used in place of more specific error codes.

@seanmonstar seanmonstar closed this Nov 5, 2026
@cristi-
cristi- deleted the cc/h2-error-codes branch November 5, 2026 21:49
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.

2 participants