Repository navigation
fix(client): flag HTTP responses truncated at the body cap - #414
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
Bodies larger than maxBodyBytes were silently cut and returned as a normal 200, so a truncated response looked successful. Read one byte past the cap (also after decompression) and set StreamError, as the SSE path already does, keeping the first maxBodyBytes of the body.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No issue filed: direct bug-fix PR, as CONTRIBUTING allows.
Cause.
HTTP.Sendreads the body withio.LimitReader(resp.Body, maxBodyBytes)anddecompressdoes the same on the decoded stream. A body larger than 64 MiB was cut at the cap with no indication: the response came back as a plain 200 andposting runreported it as passed. The SSE and gRPC paths already report this case; plain HTTP was the only silent one.Fix. Read
maxBodyBytes+1bytes (before and after decompression). If the cap is exceeded, keep the firstmaxBodyBytesbytes and setResponse.StreamErrortoresponse exceeded 64.00 MB, the same mechanism SSE uses: the body is preserved, the status becomes a warning (shown as "Stream interrupted", the existing label), andposting runno longer reports the request as passed. No new fields, cap value unchanged.Tests. New in
internal/client/http_test.go: body of cap+1 bytes, gzip body whose decoded size exceeds the cap (both fail on main:StreamErrorempty), and a body of exactly the cap (no error).Reproduction. Serve
maxBodyBytes+1bytes from anhttptestserver and callNewHTTP(...).Send; on main the response is 200 withStreamError == "".This change was prepared with the help of an AI coding assistant (Claude) and submitted on Alex's behalf; the author has not independently reviewed or run it beyond the automated tests.