oven-sh/bun · error · bun_http::Error

UnexpectedRedirect

Error message

UnexpectedRedirect

What it means

A redirect response was received when none was expected or allowed in the current context. Fires when the client received a 3xx status with Location but redirects are not permitted (e.g., after a POST upgrade or in a tunnel establishment).

Solutions

  1. Check if the server is incorrectly returning a redirect for a non-redirectable request
  2. Verify the request context allows redirect following
  3. Inspect the redirect chain for unexpected server behavior
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/http/error.rs:74 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/cc5421f2f77a708b. Report an issue: GitHub.

Appendix: source

Thrown at src/http/error.rs:74

    #[error("UnexpectedData")]
    UnexpectedData,
    #[error("InvalidHTTPResponse")]
    InvalidHTTPResponse,
    #[error("InvalidContentLength")]
    InvalidContentLength,
    #[error("UnsupportedTransferEncoding")]
    UnsupportedTransferEncoding,
    #[error("RequestBodyNotReusable")]
    RequestBodyNotReusable,
    #[error("UnsupportedRedirectProtocol")]
    UnsupportedRedirectProtocol,
    #[error("RedirectURLTooLong")]
    RedirectURLTooLong,
    #[error("RedirectURLInvalid")]
    RedirectURLInvalid,
    #[error("InvalidRedirectURL")]
    InvalidRedirectURL,
    #[error("UnexpectedRedirect")]
    UnexpectedRedirect,
    #[error("ShortRead")]
    ShortRead,
    #[error("WantRead")]
    WantRead,
    #[error("WantWrite")]
    WantWrite,
    #[error("HTTP3HandshakeFailed")]
    HTTP3HandshakeFailed,
    #[error("HTTP3ProtocolError")]
    HTTP3ProtocolError,
    #[error("HTTP3HeaderEncodingError")]
    HTTP3HeaderEncodingError,
    #[error("DNSResolutionFailed")]
    DNSResolutionFailed,
    #[error("HTTP3StreamReset")]
    HTTP3StreamReset,
    #[error("HTTP3ContentLengthMismatch")]

View on GitHub (pinned to 8c5296ac45)