{"record":{"id":"675800a287dcbf63","repo":"Hmbown/CodeWhale","slug":"bundle-redirect-location-is-invalid","errorCode":null,"errorMessage":"bundle redirect Location is invalid","messagePattern":"bundle redirect Location is invalid","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/config_bundles.rs","lineNumber":788,"sourceCode":"            // reqwest errors can include the full URL (including its query or\n            // userinfo), so keep transport failures deliberately URL-free.\n            .map_err(|_| anyhow!(\"bundle fetch request failed\"))?;\n\n        if !response.status().is_redirection() {\n            break response;\n        }\n        if redirects >= MAX_REDIRECTS {\n            bail!(\"bundle fetch exceeded the five-redirect limit\");\n        }\n        let location = response\n            .headers()\n            .get(reqwest::header::LOCATION)\n            .ok_or_else(|| anyhow!(\"bundle redirect is missing a valid Location header\"))?\n            .to_str()\n            .map_err(|_| anyhow!(\"bundle redirect is missing a valid Location header\"))?;\n        let next_url = current_url\n            .join(location)\n            .map_err(|_| anyhow!(\"bundle redirect Location is invalid\"))?;\n        validate_bundle_redirect(&initial_scheme, &next_url)?;\n        current_url = next_url;\n        redirects += 1;\n    };\n\n    if !response.status().is_success() {\n        bail!(\n            \"bundle fetch failed with HTTP status {}\",\n            response.status().as_u16()\n        );\n    }\n\n    // Read at most MAX_BUNDLE_BYTES + 1 so an oversize body is detected\n    // rather than silently truncated.\n    let mut buffer = Vec::new();\n    let body = response;\n    body.take(MAX_BUNDLE_BYTES + 1)\n        .read_to_end(&mut buffer)","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/config_bundles.rs#L770-L806","documentation":"The Location header from a redirect could not be resolved against the current URL by url::Url::join — typically a relative reference that cannot be parsed in context or a structurally malformed URL. fetch_bundle validates each hop before following it, so a broken target is refused before any request is made.","triggerScenarios":"Redirect Location value like 'http://' or otherwise malformed, making current_url.join(location) return Err while following bundle redirects.","commonSituations":"Misconfigured web servers emitting garbage Location values, proxies injecting invalid URLs, hand-written redirect handlers producing wrong relative paths.","solutions":["Fix the server to emit a syntactically valid absolute or properly relative Location URL.","Use the final bundle URL directly to skip redirects.","Check the next_url produced by the redirector for missing scheme or host."],"exampleFix":"// before (server)\nLocation: ftp:// or http://\n// after (server)\nLocation: https://host/path/bundle.toml","handlingStrategy":"validation","validationCode":"let parsed = url::Url::parse(location_header).or_else(|_| base.join(location_header)); if parsed.is_err() { eprintln!(\"server emitted unusable Location: {:?}\", location_header); }","typeGuard":null,"tryCatchPattern":"match fetch_bundle(url) { Err(e) if e.to_string().contains(\"Location is invalid\") => eprintln!(\"fix or bypass the redirector\"), other => other?, }","preventionTips":["Emit absolute, well-formed Location URLs from redirects.","Test relative-redirect handling of your mirror.","Bypass redirectors by fetching final URLs."],"tags":["http","redirect","url"],"backgroundTag":"invalid-url-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T21:17:16.096Z"}