Skip to content

[HTTPTransport] Non-2xx HTTP responses treated as success and redundant fallback retries on blocked routes #7844

Closed as not planned

Description

@omer-bahashwan

How do you use Sentry?

Sentry Saas (sentry.io)

Version

sentry-sdk[fastapi]>=2.0,<3.0

Steps to Reproduce

  1. 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.
  2. Implement a custom multi-route or dual-transport wrapper that attempts direct delivery and falls back to an alternate tunnel endpoint upon failure.
  3. Trigger a test exception via sentry_sdk.capture_exception().
  4. Observe how HTTP 403/404 responses are handled by HTTPTransport._handle_response().

Expected Result

  1. 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.
  2. 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

  1. 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.
  2. Redundant retry attempts continue targeting the blocked endpoint on subsequent events, severely delaying application boot/shutdown times due to repeated network connection timeouts.

Activity

  1. linear-code commented on Oct 3, 2026

    @linear-code
  2. added 2 commits that reference this issue on Oct 5, 2026
    3edc769
    e1146fe
  3. ericapisani commented on Oct 5, 2026

    @ericapisani
    Member

    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 transport option 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.

  4. omer-bahashwan commented on Oct 9, 2026

    @omer-bahashwan
    Author

    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 transport option during sentry_sdk.init() works smoothly for our air-gapped/filtered environment. Appreciate you confirming that this is the recommended approach!

    Best,
    Omar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions