Skip to content

fix: abort incomplete streamed responses - #245

Merged
ovaistariq merged 3 commits into
mainfrom
perfloop-pr-open-jbd53f0x6f
Oct 21, 2026
Merged

ovaistariq merged 3 commits into
mainfrom
perfloop-pr-open-jbd53f0x6f

Conversation

@perfloop

@perfloop perfloop Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

TAG now returns upstream body-copy failures and aborts a committed downstream response instead of finishing framing around a received prefix. It never appends S3 error XML after headers are committed.

HTTP/1.0 normally uses connection close to end an unknown-length body, so this path resets the underlying TCP connection; TLS uses the underlying TCP socket as well. HTTP/1.1 and HTTP/2 use http.ErrAbortHandler.

Upstream status, rather than downstream delivery, owns write bookkeeping. Confirmed 2xx streamed PUT and DELETE operations still invalidate cache state, and tiered PUTs still publish their upstream marker when caching is enabled. The write-through tee holds its reservation until its asynchronous cache work completes. A rejected write does not trigger post-forward invalidation.

TestRoutedListBucketsTruncatedUpstreamResponseAborts sends authenticated signing-mode ListBuckets through the real router to an upstream that sends chunked HTTP 200 and closes before the terminal chunk. It requires a transport or body-read error for HTTP/1.1 (including Connection: close), plain and TLS HTTP/1.0, and HTTP/2. TestRoutedListBucketsCompleteResponsesRemainComplete passes on comparison revision 19e1370439c826758a348bdf887d8ad0337ac2a6 and final revision 0a25dcb2711c48eae0deceb4d29fd2dabe9c810c; it covers known- and unknown-length responses. TestRoutedListBucketsAuthFailureBeforeCommitmentRemainsS3Error also passes on both revisions and preserves pre-header signature errors.

TestExecuteAndStreamReturningMetaReturnsBodyReadError checks that a copy error preserves status and ETag. TestHandlePutObject_ReinvalidatesAfterResponseCopyError and TestHandleDeleteObject_ReinvalidatesAfterResponseCopyError cover post-2xx invalidation; TestHandlePutObject_Non2xxResponseCopyErrorKeepsRacingRefill and TestHandleDeleteObject_Non2xxResponseCopyErrorKeepsRacingRefill preserve rejected-write refills. The tiered tests TestTieredUpstreamPutCommitsMarkerAfterResponseCopyError, TestTieredRejectedUpstreamPutWithResponseCopyErrorKeepsLocalObject, TestTieredDeleteConvergesAfterResponseCopyError, and TestTieredRejectedDeleteWithResponseCopyErrorKeepsMarker preserve marker state for confirmed and rejected writes. TestHandlePutObject_WriteThroughTee_ResponseCopyErrorInvalidatesAndReleasesReservation checks tee reservation lifetime.

This condition holds with this change and does not hold at 19e1370439c826758a348bdf887d8ad0337ac2a6: For authenticated ListBuckets GETs through handlers.Server.Router in signing mode over HTTP/1.0 (plain or TLS), HTTP/1.1, and HTTP/2, a chunked upstream HTTP 200 closed before its terminal chunk must make the client observe a transport or body-read error rather than complete the truncated prefix as success..

The six repository checks make build, make test, make test-integration, make test-race, make test-coverage, and make lint-ci passed. The shell adapter used to report the comparison is not included in this pull request; the native regression tests are. Production frequency and SDK-specific effects remain unmeasured. Response-capture operations use a separate path and are unchanged.


Generated by Perfloop.


Note

Medium Risk
Changes core HTTP streaming and post-mutation cache invalidation when clients disconnect mid-response; behavior is well-tested but affects all proxied streaming traffic and write paths.

Overview
Streamed upstream responses now fail closed when body delivery breaks. The forwarder propagates io.Copy errors after status/headers are committed, and handleWithError aborts via http.ErrAbortHandler instead of logging and leaving a truncated success or appending S3 error XML.

Cache and tiered bookkeeping follow upstream HTTP status, not client delivery success. Confirmed 2xx streamed PUT/DELETE still run post-forward re-invalidation (and tiered marker/delete convergence) when the response body fails to reach the client; non-2xx responses still skip that work so racing refills are preserved.

Docs describe this direct-streaming behavior. New router and proxy tests cover truncated ListBuckets across HTTP/1.0–HTTP/2, body-copy errors on forward, and invalidation/marker/tee-reservation paths after delivery failures.

Reviewed by Cursor Bugbot for commit 26f9003. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with its explicitly accepted HTTP/1.0 limitation.

Summary

TAG returns upstream body-copy errors and aborts responses after headers are sent, without appending S3 error XML.

  • A streamed response copy failure now aborts the client response.
  • Cache updates follow upstream write status, not response delivery.

Reviews (3) · Last reviewed commit: "fix(forward): drop the HTTP/1.0 reset pa..." · Reviewed by Greptile

@perfloop
perfloop Bot force-pushed the perfloop-pr-open-jbd53f0x6f branch from 712e2b5 to 0a25dcb Compare October 21, 2026 09:44
When a streamed upstream body fails mid-copy after the status is
committed, handleWithError aborts the response with
panic(http.ErrAbortHandler). The previous version special-cased
HTTP/1.0 requests: it hijacked the connection, unwrapped tls.Conn to
the TCP socket, and SetLinger(0)'d it so the close went out as a TCP
RST, on the theory that a 1.0 client (which reads an unknown-length
body to EOF) could otherwise not distinguish truncation from
completion.

That path is removed. Hijack plus a forced RST is a fragile, transport-
specific hack for a protocol no real client uses against TAG, and it
bypassed the sanctioned Go abort. HTTP/1.0 now takes the same
ErrAbortHandler path as HTTP/1.1 and HTTP/2: Go closes the connection
without finishing the framing. A 1.0 client cannot tell that from a
complete response, and that limitation is accepted and noted at the
abort site.

Tests: the HTTP/1.0 and HTTP/1.0+TLS truncation cases are replaced by a
single HTTP/1.0 case that asserts only that the handler aborts (the
connection closes, nothing beyond the upstream prefix and no error XML
is delivered) without asserting the client can observe truncation. The
HTTP/1.1 and HTTP/2 cases and the PUT/DELETE/tiered-marker gating tests
are unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6
(cherry picked from commit d843d2fa43065a7cd2d1af83ba6440e012f101cf)
@ovaistariq
ovaistariq merged commit b7ffb50 into main Oct 21, 2026
9 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-jbd53f0x6f branch October 21, 2026 18:35
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.22.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants