Skip to content

fix(provider): render transport error phase and causes instead of reqwest kind - #106

Merged
lg2m merged 1 commit into
mainfrom
fix/provider-transport-error-cause
Sep 21, 2026
Merged

lg2m merged 1 commit into
mainfrom
fix/provider-transport-error-cause

Conversation

@lg2m

@lg2m lg2m commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

A session failed with:

error: provider request failed: error decoding response body

transport_error in crates/qq-provider/src/http.rs displayed reqwest::Error directly. reqwest's Display prints only its kind label and drops the source chain, and Response::bytes_stream() files every body read failure under Kind::Decode. So a read timeout, a peer reset, and a truncated chunked body all surfaced as the same "error decoding response body" — nothing about JSON or SSE decoding was involved.

Observed run (09853b7b981dc894968872a9f5fb2555, litellm/us.anthropic.claude-fable-5-1): turn 12 received 200 text/event-stream headers and then no bytes for 300 s. reqwest's ReadTimeoutBody fired TimedOut → wrapped as Kind::Body → re-wrapped by bytes_stream as Kind::Decode → rendered as the message above. The run failed 304 s after the previous turn completed, matching READ_TIMEOUT.

Change

New describe_transport names the phase itself and appends the non-reqwest causes from the source chain:

Before After
provider request failed: error decoding response body (stall) provider request failed: timed out waiting for response body (no bytes for 300s, or request past 1800s)
provider request failed: error decoding response body (peer cut mid-body) provider request failed: response body failed: error reading a body from connection: end of file before message length reached

Connect/header timeouts, connection failures, redirects, and builder errors get their own phase labels. The URL stays excluded (may carry credentials; the caller names the provider) and the existing redaction pass is unchanged.

Not in scope: the behavior that made the stall unrecoverable. The stream had yielded zero events so it was retry-eligible, but the AttemptPolicy 30 s total budget was exhausted after the 300 s wait, so it gave up on attempt 1. Whether a first-byte stall should be retried outside the budget, or whether 300 s idle is too generous before the first SSE event, is a policy decision for a separate issue.

Tests

  • stalled_body_transport_error_names_the_timeout — server sends 200 + SSE headers then nothing, against a 100 ms read timeout; asserts the message names the body timeout and does not contain the reqwest label.
  • truncated_body_transport_error_carries_the_cause — chunked body cut mid-chunk; asserts the phase prefix and a non-empty cause chain.

Verification

  • cargo test -p qq-provider — 210 passed
  • cargo test -p qq-provider --no-default-features --features test-support — 163 passed
  • cargo test --workspace — green
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • cargo fmt --all -- --check — clean

Impact

Error-path only; no change to the streaming hot path. docs/design/providers.md records the rendering contract.

Linear: the linear_mcp OAuth connection needs reauthorization, so no DEV issue is linked yet; will link once reconnected.

…west kind

`transport_error` displayed `reqwest::Error` directly, whose `Display` prints
only the kind label and drops the source chain. `bytes_stream` files every
body read failure under `Kind::Decode`, so a read timeout, peer reset, or
truncated chunked body all surfaced as the bare
`provider request failed: error decoding response body`.

Observed in run 09853b7b981dc894968872a9f5fb2555: LiteLLM returned 200
text/event-stream headers, then sent nothing for the 300 s READ_TIMEOUT.
The run failed with the decode message and no hint that it was a stall.

`describe_transport` now names the phase (connection, headers, body,
redirect), reports which deadline expired with its configured seconds for
timeouts, and appends the non-reqwest causes from the source chain. The URL
stays out; the redaction pass is unchanged.

Regression tests cover a stalled body under a short read timeout and a
truncated chunked body; the design doc records the rendering contract.
@lg2m
lg2m merged commit 887800e into main Sep 21, 2026
4 checks passed
@lg2m
lg2m deleted the fix/provider-transport-error-cause branch September 21, 2026 19:56
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.

1 participant