{"record":{"id":"00d72ba281ec6920","repo":"clockworklabs/SpacetimeDB","slug":"http-response-from-url-url-was-success-but-did","errorCode":null,"errorMessage":"HTTP response from url ({url}) was success but did not have content-type: {content_type}","messagePattern":"HTTP response from url \\((.+?)\\) was success but did not have content-type: (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/util.rs","lineNumber":83,"sourceCode":"        Some(\"HTTP status server error\")\n    } else {\n        Some(\"unexpected HTTP status code\")\n    }\n}\n\nimpl ResponseExt for reqwest::Response {\n    async fn ensure_content_type(self, content_type: &str) -> anyhow::Result<Self> {\n        let status = self.status();\n        if self\n            .headers()\n            .get(http::header::CONTENT_TYPE)\n            .is_some_and(|ty| ty == content_type)\n        {\n            return Ok(self);\n        }\n        let url = self.url();\n        let Some(status_desc) = err_status_desc(status) else {\n            anyhow::bail!(\"HTTP response from url ({url}) was success but did not have content-type: {content_type}\");\n        };\n        let url = url.to_string();\n        let status_err = match self.error_for_status_ref() {\n            Err(e) => anyhow::Error::from(e),\n            Ok(_) => anyhow::anyhow!(\"{status_desc} ({status}) from url ({url})\"),\n        };\n        let err = match self.text().await {\n            Ok(text) => status_err.context(text),\n            Err(err) => anyhow::Error::from(err)\n                .context(format!(\"{status_desc} ({status})\"))\n                .context(\"failed to get response text\"),\n        };\n        Err(err)\n    }\n\n    async fn json_or_error<T: serde::de::DeserializeOwned>(self) -> anyhow::Result<T> {\n        let status = self.status();\n        self.ensure_content_type(\"application/json\")","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/util.rs#L65-L101","documentation":"ResponseExt::ensure_content_type verifies that a successful HTTP response carries exactly the expected Content-Type header before the body is consumed. This specific message fires when the status is a success (2xx) but the header is missing or different. The comparison is exact string equality, so a server sending `application/json; charset=utf-8` will not match an expected `application/json`.","triggerScenarios":"Passing a URL that returns an HTML page (website root, redirect target, login/placeholder page) where the CLI expects a typed artifact; a reverse proxy serving index.html with 200 for unknown paths; the server appending charset parameters to the content type; a CDN rewriting responses.","commonSituations":"Wrong --url flag pointing at the marketing site instead of the API/artifact host; nginx `try_files` fallback masking 404s as HTML; trailing-slash redirects landing on an index page; endpoint moved and old URL now serves a page.","solutions":["Inspect what is actually served: `curl -sI <url>` and check Content-Type (and Location for redirects)","Correct the URL to the real artifact/API endpoint (scheme, host, path)","If you control the server, make the endpoint return the exact expected Content-Type with no extra parameters","Follow or eliminate redirects so the final response is the artifact itself"],"exampleFix":"# before: URL serves an HTML page with 200\n$ curl -sI https://host/module.wasm | grep -i content-type\ncontent-type: text/html\n\n# after: artifact endpoint returns the expected type exactly\n$ curl -sI https://host/module.wasm | grep -i content-type\ncontent-type: application/wasm","handlingStrategy":"try-catch","validationCode":"// check before downloading\nlet resp = client.head(url).send().await?;\nlet ct = resp.headers().get(http::header::CONTENT_TYPE).and_then(|v| v.to_str().ok());\nanyhow::ensure!(ct == Some(\"application/wasm\"), \"unexpected content-type {ct:?} at {url}\");","typeGuard":null,"tryCatchPattern":"match resp.ensure_content_type(\"application/wasm\").await {\n    Ok(r) => r.bytes().await?,\n    Err(e) => {\n        // never parse an HTML page as binary; surface the url + hint instead\n        return Err(e.context(format!(\"bad content-type at {url} - is this the artifact endpoint?\")));\n    }\n}","preventionTips":["Validate configured URLs once at startup (HEAD + content-type check) with a clear error","Follow redirects explicitly or point at the final artifact URL","Integration-test the endpoint's exact Content-Type, including charset-free values","Configure proxies/CDNs to preserve the upstream Content-Type"],"tags":["http","network","content-type","download","cli"],"backgroundTag":"http-unexpected-content-type","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}