{"record":{"id":"8818b9d5601d5214","repo":"astral-sh/uv","slug":"http-status-location-value-redirect-url-is","errorCode":null,"errorMessage":"HTTP {status} 'Location' value `{redirect_url}` is not a valid HTTP URI: {err}","messagePattern":"HTTP (.+?) 'Location' value `(.+?)` is not a valid HTTP URI: (.+?)","errorType":"http","errorClass":"reqwest_middleware::Error","httpStatus":null,"severity":"error","filePath":"crates/uv-client/src/base_client.rs","lineNumber":1024,"sourceCode":"        Err(DisplaySafeUrlError::Url(ParseError::RelativeUrlWithoutBase)) => original_req_url.join(location).map_err(|err| {\n            reqwest_middleware::Error::Middleware(anyhow!(\n                \"Invalid HTTP {status} 'Location' value `{location}` relative to `{original_req_url}`: {err}\"\n            ))\n        })?,\n        Err(err) => {\n            return Err(reqwest_middleware::Error::Middleware(anyhow!(\n                \"Invalid HTTP {status} 'Location' value `{location}`: {err}\"\n            )));\n        }\n    };\n    // Per RFC 7231, fragments must be propagated\n    if let Some(fragment) = original_req_url.fragment() {\n        redirect_url.set_fragment(Some(fragment));\n    }\n\n    // Ensure the URL is a valid HTTP URI.\n    if let Err(err) = redirect_url.as_str().parse::<http::Uri>() {\n        return Err(reqwest_middleware::Error::Middleware(anyhow!(\n            \"HTTP {status} 'Location' value `{redirect_url}` is not a valid HTTP URI: {err}\"\n        )));\n    }\n\n    if redirect_url.scheme() != \"http\" && redirect_url.scheme() != \"https\" {\n        return Err(reqwest_middleware::Error::Middleware(anyhow!(\n            \"Invalid HTTP {status} 'Location' value `{redirect_url}`: scheme needs to be https or http\"\n        )));\n    }\n\n    let mut headers = HeaderMap::new();\n    std::mem::swap(req.headers_mut(), &mut headers);\n\n    let cross_host = redirect_url.host_str() != original_req_url.host_str()\n        || redirect_url.port_or_known_default() != original_req_url.port_or_known_default();\n    if cross_host {\n        if cross_origin_credentials_policy == CrossOriginCredentialsPolicy::Secure {\n            debug!(\"Received a cross-origin redirect. Removing sensitive headers.\");","sourceCodeStart":1006,"sourceCodeEnd":1042,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv-client/src/base_client.rs#L1006-L1042","documentation":"Error \"HTTP {status} 'Location' value `{redirect_url}` is not a valid HTTP URI: {err}\" thrown in astral-sh/uv.","triggerScenarios":"Thrown at crates/uv-client/src/base_client.rs:1024 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}