You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HTTPTransport] Non-2xx HTTP responses treated as success and redundant fallback retries on blocked routes #7844
Set up sentry-sdk in a Python application behind a restrictive network/DNS filter where direct access to *.ingest.sentry.io is blocked or returns HTTP 403/404 from a local network middlebox.
Implement a custom multi-route or dual-transport wrapper that attempts direct delivery and falls back to an alternate tunnel endpoint upon failure.
Trigger a test exception via sentry_sdk.capture_exception().
Observe how HTTP 403/404 responses are handled by HTTPTransport._handle_response().
Expected Result
HTTPTransport should treat explicit non-2xx HTTP error status codes (such as 403 Forbidden or 404 Not Found) as transport-level delivery failures, raising an exception that can be caught by custom/wrapper transports to trigger failover routing immediately.
Subsequent event delivery attempts should allow short-circuiting a known blocked route to avoid compounding network timeout delays (up to 60s) on every event flush.
Actual Result
HTTPTransport only logs a warning for non-2xx codes (excluding 429) without raising an exception, causing wrapper transports to assume the delivery succeeded and silently dropping failover attempts.
Redundant retry attempts continue targeting the blocked endpoint on subsequent events, severely delaying application boot/shutdown times due to repeated network connection timeouts.
The HTTPTransport isn't treating those errors as 'success'es, but are instead recording them as lost events (see here). If an exception were to be raised at this point without a custom transport to catch it, the SDK could break user applications.
For a workflow such as what you've described, I'd suggest using the transportoption in the initial client configuration to provide a custom transport to replace the HTTPTransport so that exceptions are raised in the way that you're looking for.
That completely makes sense—protecting the host application from runtime exceptions caused by the monitoring layer is a crucial design guarantee.
Passing our dual-route transport with the health registry via the transport option during sentry_sdk.init() works smoothly for our air-gapped/filtered environment. Appreciate you confirming that this is the recommended approach!
Activity
linear-code commentedon Oct 3, 2026
PY-2923
fix(transport): raise TransportResponseError on unexpected HTTP status
fix(transport): raise TransportResponseError on unexpected HTTP status
ericapisani commentedon Oct 5, 2026
Hi @omer-bahashwan ,
Thanks for reaching out!
The HTTPTransport isn't treating those errors as 'success'es, but are instead recording them as lost events (see here). If an exception were to be raised at this point without a custom transport to catch it, the SDK could break user applications.
For a workflow such as what you've described, I'd suggest using the
transportoption in the initial client configuration to provide a custom transport to replace theHTTPTransportso that exceptions are raised in the way that you're looking for.omer-bahashwan commentedon Oct 9, 2026
Hi @ericapisani,
Thanks for the quick response and clarification!
That completely makes sense—protecting the host application from runtime exceptions caused by the monitoring layer is a crucial design guarantee.
Passing our dual-route transport with the health registry via the
transportoption duringsentry_sdk.init()works smoothly for our air-gapped/filtered environment. Appreciate you confirming that this is the recommended approach!Best,
Omar