Skip to content

fix(git): Report a provider stream breaking mid-response as a coded error - #172

Open
vaind wants to merge 1 commit into
mainfrom
ivan/relay-stream-errors-3da2e1
Open

vaind wants to merge 1 commit into
mainfrom
ivan/relay-stream-errors-3da2e1

Conversation

@vaind

@vaind vaind commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Before a relayed response starts, relay failures become coded errors that GitServer reports through emit_error. Once the body was streaming, they reached the caller as raw urllib3 exceptions instead, without the scm-git fingerprint or the request's tags.

  • Relay: errors while reading the body now map to the same coded errors as before the response, raised from None:
    • a read timeout becomes ResourceGatewayTimeout;
    • a broken connection or a body cut off early becomes ResourceServiceUnavailable;
    • any other urllib3 error becomes ResourceBadGateway.
  • Server: passes the coded error to emit_error with the request's tags, still counts it as stream_interrupted, then raises it again. The status line is already sent, so raising is what makes the WSGI server drop the connection instead of ending the response as if it were complete.

Sentry's endpoint needs no change. Its SDK will also capture the raised error, and a before_send rule can drop that duplicate if it's noisy.

Tested end to end against the fake upstream (a chunk cut off mid-body, and a read timeout), plus unit tests for each mapping. Each test checks that the body bytes appear nowhere in the reported exception chain.

🤖 Generated with Claude Code

…rror

Once a relayed response had started, a provider failure reached the caller
as the raw urllib3 exception chained to http.client's, so Sentry grouped it
as an unrelated issue without the request's tags. The same failure before
the response is a coded error that GitServer reports through emit_error.

The relay now raises the same coded errors while it reads the body as it
does for the request, without the library exceptions chained: a read
timeout is a ResourceGatewayTimeout, a broken connection or a body cut off
early a ResourceServiceUnavailable, anything else from urllib3 a
ResourceBadGateway. GitServer passes the error to emit_error with the
request's tags, then still raises it, so the WSGI server drops the
connection rather than ending the response as if it were whole. It is
still counted as stream_interrupted, so existing counts keep their meaning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vaind
vaind requested a review from a team as a code owner November 3, 2026 07:16
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