Repository navigation
Name a broken answer body instead of "error decoding response body" - #344
Merged
Merged
Conversation
reqwest 0.13 reports every failure while reading a response body as a decode error, so an upstream that hung up mid-answer reached the UI as "Forwarding failed: error decoding response body", which reads like a decoding bug and drops the actual cause (the source chain). - Body-read failures get their own code, gw.upstream.body_broken, with the causes spelled out (e.g. "error reading a body from connection: end of file before message length reached"). The extra reqwest layer added by the replayed opening is skipped so the cause is told once. - gw.upstream.forward_failed now carries every cause too, with the URL reduced to its origin. - gw.upstream.body_broken is listed in FAILED_AFTER_SENDING. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
reqwest 0.13 maps every error while reading a response body to
Kind::Decode, whoseDisplayis onlyerror decoding response body.map_reqwest_errorformatted the error withDisplayalone, so an upstream (or a proxy in between) that closed the connection mid-answer showed up asForwarding failed: error decoding response body. That reads like a decoding bug, and the real cause (end of file before message length reached,connection reset by peer, an HTTP/2 stream reset, ...) only lives insource()and was lost.Change
gw.upstream.body_broken: "The connection to the upstream broke while the answer was being received: {detail}", wheredetailis the cause chain. A decode error whose chain holds aserde_json::Error(ajson()parse failure) is not treated as a broken connection.opening.rs,Body::wrap_stream) adds is skipped, so the cause is not preceded by a second "error decoding response body".gw.upstream.forward_failednow carries every cause as well; a URL in the top-level message is reduced to its origin withtw_secret::redact_url.gw.upstream.body_brokenis added toFAILED_AFTER_SENDING(the upstream did receive the request);msg-codes.txtregenerated.The code is new, so Lite needs a Chinese sentence for it when it next bumps its core pin (its
msg_codestest will require it).Tests
forward::tests: a body cut short, the same break behind a replayed opening, and the cause chain with the URL redacted.passthrough::a_stream_that_dies_midway_says_so_instead_of_just_stoppingnow also checks the code and the cause.🤖 Generated with Claude Code