{"record":{"id":"252b4567456eb2da","repo":"zed-industries/zed","slug":"missing-content-type-header","errorCode":null,"errorMessage":"missing Content-Type header","messagePattern":"missing Content-Type header","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/agent_ui/src/mention_set.rs","lineNumber":1476,"sourceCode":"\n    let mut response = http_client.get(&url, AsyncBody::default(), true).await?;\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 response.status().is_client_error() {\n        let text = String::from_utf8_lossy(body.as_slice());\n        anyhow::bail!(\n            \"status error {}, response: {text:?}\",\n            response.status().as_u16()\n        );\n    }\n\n    let Some(content_type) = response.headers().get(\"content-type\") else {\n        anyhow::bail!(\"missing Content-Type header\");\n    };\n    let content_type = content_type\n        .to_str()\n        .context(\"invalid Content-Type header\")?;\n    let content_type = match content_type {\n        \"text/html\" => ContentType::Html,\n        \"text/plain\" => ContentType::Plaintext,\n        \"application/json\" => ContentType::Json,\n        _ => ContentType::Html,\n    };\n\n    match content_type {\n        ContentType::Html => {\n            let mut handlers: Vec<TagHandler> = vec![\n                Rc::new(RefCell::new(markdown::WebpageChromeRemover)),\n                Rc::new(RefCell::new(markdown::ParagraphHandler)),\n                Rc::new(RefCell::new(markdown::HeadingHandler)),\n                Rc::new(RefCell::new(markdown::ListHandler)),","sourceCodeStart":1458,"sourceCodeEnd":1494,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent_ui/src/mention_set.rs#L1458-L1494","documentation":"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.","triggerScenarios":"Mentioning a URL served by a misconfigured static server, a hand-rolled HTTP service, or a proxy that strips the Content-Type header.","commonSituations":"Localhost dev servers without proper MIME configuration; embedded or minimal HTTP servers; CDN/proxy misconfiguration.","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)."],"exampleFix":"// before\nlet Some(content_type) = response.headers().get(\"content-type\") else {\n    anyhow::bail!(\"missing Content-Type header\");\n};\n// after: fall back to a default instead of failing\nlet content_type = response\n    .headers()\n    .get(\"content-type\")\n    .and_then(|value| value.to_str().ok())\n    .unwrap_or(\"text/plain\");","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["zed","http","headers","url-mention"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}