zed-industries/zed · warning
missing Content-Type header
Error message
missing Content-Type header
What it means
After fetching a URL mention, Zed requires a Content-Type response header to choose the converter (text/html, text/plain, application/json; anything else defaults to HTML). This error means the server sent no Content-Type at all, so no parser can be selected.
Source
Thrown at crates/agent_ui/src/mention_set.rs:1476
let mut response = http_client.get(&url, AsyncBody::default(), true).await?;
let mut body = Vec::new();
response
.body_mut()
.read_to_end(&mut body)
.await
.context("error reading response body")?;
if response.status().is_client_error() {
let text = String::from_utf8_lossy(body.as_slice());
anyhow::bail!(
"status error {}, response: {text:?}",
response.status().as_u16()
);
}
let Some(content_type) = response.headers().get("content-type") else {
anyhow::bail!("missing Content-Type header");
};
let content_type = content_type
.to_str()
.context("invalid Content-Type header")?;
let content_type = match content_type {
"text/html" => ContentType::Html,
"text/plain" => ContentType::Plaintext,
"application/json" => ContentType::Json,
_ => ContentType::Html,
};
match content_type {
ContentType::Html => {
let mut handlers: Vec<TagHandler> = vec![
Rc::new(RefCell::new(markdown::WebpageChromeRemover)),
Rc::new(RefCell::new(markdown::ParagraphHandler)),
Rc::new(RefCell::new(markdown::HeadingHandler)),
Rc::new(RefCell::new(markdown::ListHandler)),View on GitHub (pinned to bc538def45)
Solutions
- Fix the server to send a correct Content-Type header.
- Serve the document from a correctly configured host (or a paste service).
- In code, default to text/plain instead of failing when the header is absent (see example fix).
Example fix
// before
let Some(content_type) = response.headers().get("content-type") else {
anyhow::bail!("missing Content-Type header");
};
// after: fall back to a default instead of failing
let content_type = response
.headers()
.get("content-type")
.and_then(|value| value.to_str().ok())
.unwrap_or("text/plain"); Defensive patterns
Strategy: fallback
Prevention
- Default to text/plain when Content-Type is absent instead of failing.
- Sniff the first bytes of the body ('<', '{', plain text) as a secondary signal.
- Log the offending URL so misconfigured servers are identifiable.
When it happens
Trigger: Mentioning a URL served by a misconfigured static server, a hand-rolled HTTP service, or a proxy that strips the Content-Type header.
Common situations: Localhost dev servers without proper MIME configuration; embedded or minimal HTTP servers; CDN/proxy misconfiguration.
Related errors
- Could not find UNIT_DATA in the file
- Failed to parse UNIT_DATA as JSON: ${e.message}
- HTTP error! status: ${response.status}
- GraphQL error: ${JSON.stringify(data.errors)}
- Unexpected response structure: ${JSON.stringify(data)}
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/252b4567456eb2da.
Report an issue: GitHub.