zed-industries/zed · error
refusing to follow redirect to non-HTTP(S) URL
Error message
refusing to follow redirect to non-HTTP(S) URL {target} What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/agent/src/tools/fetch_tool.rs:99 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/7e6b3f460e79269d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent/src/tools/fetch_tool.rs:99
let normalized = normalize_url(url);
let mut response = http_client
.get(&normalized, AsyncBody::default(), false)
.await?;
let status = response.status();
if status.is_redirection() {
let location = response
.headers()
.get("location")
.context("redirect response is missing a Location header")?
.to_str()
.context("redirect response has an invalid Location header")?;
let target = url::Url::parse(&normalized)
.with_context(|| format!("could not parse URL {normalized:?}"))?
.join(location)
.with_context(|| format!("invalid redirect target {location:?}"))?;
anyhow::ensure!(
matches!(target.scheme(), "http" | "https"),
"refusing to follow redirect to non-HTTP(S) URL {target}"
);
return Ok(FetchStep::Redirect(target.to_string()));
}
let mut body = Vec::new();
response
.body_mut()
.read_to_end(&mut body)
.await
.context("error reading response body")?;
if status.is_client_error() {
let text = String::from_utf8_lossy(body.as_slice());
bail!("status error {}, response: {text:?}", status.as_u16());
}
View on GitHub (pinned to f4178619ac)