{"record":{"id":"7e6b3f460e79269d","repo":"zed-industries/zed","slug":"refusing-to-follow-redirect-to-non-http-s-url-ta","errorCode":null,"errorMessage":"refusing to follow redirect to non-HTTP(S) URL {target}","messagePattern":"refusing to follow redirect to non-HTTP\\(S\\) URL (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/fetch_tool.rs","lineNumber":99,"sourceCode":"        let normalized = normalize_url(url);\n\n        let mut response = http_client\n            .get(&normalized, AsyncBody::default(), false)\n            .await?;\n\n        let status = response.status();\n        if status.is_redirection() {\n            let location = response\n                .headers()\n                .get(\"location\")\n                .context(\"redirect response is missing a Location header\")?\n                .to_str()\n                .context(\"redirect response has an invalid Location header\")?;\n            let target = url::Url::parse(&normalized)\n                .with_context(|| format!(\"could not parse URL {normalized:?}\"))?\n                .join(location)\n                .with_context(|| format!(\"invalid redirect target {location:?}\"))?;\n            anyhow::ensure!(\n                matches!(target.scheme(), \"http\" | \"https\"),\n                \"refusing to follow redirect to non-HTTP(S) URL {target}\"\n            );\n            return Ok(FetchStep::Redirect(target.to_string()));\n        }\n\n        let mut body = Vec::new();\n        response\n            .body_mut()\n            .read_to_end(&mut body)\n            .await\n            .context(\"error reading response body\")?;\n\n        if status.is_client_error() {\n            let text = String::from_utf8_lossy(body.as_slice());\n            bail!(\"status error {}, response: {text:?}\", status.as_u16());\n        }\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/fetch_tool.rs#L81-L117","documentation":"Security guard in fetch_step: the target of an HTTP redirect is not an http/https URL (e.g. file:, ftp:, or a custom scheme), so following it is refused to prevent the fetch tool from being redirected into non-web protocols.","triggerScenarios":"Thrown at crates/agent/src/tools/fetch_tool.rs:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fetch the intended resource directly with a supported http/https URL","Check the server's redirect chain for a bad Location header","Update the URL to the final http(s) destination if it is known"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}