Skip to content

fix(net): preserve response status before decoding gzip - #2903

Open
pcbeingused33 wants to merge 1 commit into
frain-dev:mainfrom
pcbeingused33:fix/preserve-gzip-response-status
Open

pcbeingused33 wants to merge 1 commit into
frain-dev:mainfrom
pcbeingused33:fix/preserve-gzip-response-status

Conversation

@pcbeingused33

Copy link
Copy Markdown

Preserve the HTTP status and response headers when a gzip response cannot be initialized.

Dispatcher.do currently records response metadata after constructing the gzip reader. If the endpoint sends Content-Encoding: gzip with an invalid gzip header (for example a non-gzip or empty body), or the response size limit truncates the gzip header, it returns an error with StatusCode still zero despite receiving an HTTP response. At-most-once delivery treats that zero as no response and can retry a delivery the endpoint already accepted.

Capture the status and headers as soon as client.Do succeeds, before decoding the body. Decoding errors still propagate; successful responses and transport errors retain their existing handling. No configuration or API changes are required.

Testing and validation

  • Added local HTTP server regression cases for a valid gzip response truncated by a one-byte response limit and an invalid gzip header. Both assert the decoding error and preservation of status 200, status text, and headers.
  • go test ./net -run '^TestDispatcherDoPreservesHeadersOnInvalidGzip$' -count=1: both cases fail before the fix (status 0) and pass afterward.
  • go test ./net -count=1: passes.
  • go test -race ./net -count=1: passes (includes the default vet checks).

AI assistance: this change and regression tests were prepared using Codex.

@CLAassistant

CLAassistant commented Nov 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pcbeingused33

Copy link
Copy Markdown
Author

Hi, just a gentle ping on this one in case it slipped through. Happy to adjust anything if needed. Thanks!

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