{"record":{"id":"43dfa84444234864","repo":"jdx/mise","slug":"remote-cache-blob-pack-has-an-invalid-content-type","errorCode":null,"errorMessage":"remote cache blob pack has an invalid content type","messagePattern":"remote cache blob pack has an invalid content type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mise-cache-core/src/lib.rs","lineNumber":596,"sourceCode":"                .send()\n                .await?;\n            if matches!(\n                response.status(),\n                StatusCode::NOT_FOUND\n                    | StatusCode::METHOD_NOT_ALLOWED\n                    | StatusCode::NOT_IMPLEMENTED\n            ) {\n                return Ok(None);\n            }\n            let response = response.error_for_status()?;\n            let media_type = response\n                .headers()\n                .get(CONTENT_TYPE)\n                .and_then(|value| value.to_str().ok())\n                .and_then(|value| value.split(';').next())\n                .map(str::trim);\n            if media_type != Some(BLOB_PACK_MEDIA_TYPE) {\n                bail!(\"remote cache blob pack has an invalid content type\");\n            }\n            Ok(Some(\n                decode_blob_pack(response, digests, staging_dir).await?,\n            ))\n        });\n        tokio::time::timeout(download_timeout, download)\n            .await\n            .map_err(|_| eyre!(\"remote cache blob pack download timed out for {url}\"))?\n    }\n\n    pub async fn get_action_result(\n        &self,\n        action: &CacheDigest,\n    ) -> Result<Option<RemoteActionResult>> {\n        let url = self.action_result_endpoint(action)?;\n        let result = retry_async(\"GET\", &url, self.retries, || async {\n            let response = self\n                .request(reqwest::Method::GET, url.clone(), ACTION_RESULT_MEDIA_TYPE)","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/crates/mise-cache-core/src/lib.rs#L578-L614","documentation":"When downloading a blob pack, the client checks the response's Content-Type media type and requires it to be the expected BLOB_PACK_MEDIA_TYPE. Any other content type (including a missing header or one prefixed with unexpected parameters) is rejected before decoding begins. This guards against a proxy or misconfigured server returning HTML error pages or JSON in place of the pack.","triggerScenarios":"POSTing the digest list to the blobs:pack endpoint and receiving a 200 response whose Content-Type is not the blob-pack media type (e.g. application/json, text/html from an auth proxy, or a truncated/parameterized header).","commonSituations":"An auth proxy or CDN intercepting the request and returning an HTML login/error page with 200; a server that supports the endpoint but responds with the wrong media type; content-type sniffing middleware rewriting headers.","solutions":["Check what the endpoint actually returned (curl -i with the same headers) to see the offending content type","Fix the reverse proxy/CDN so it passes the blob-pack endpoint through unmodified","Upgrade or fix the cache server so successful pack responses carry the correct Content-Type","Verify the client is hitting the correct v{N}/blobs:pack endpoint, not an error route"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let resp = client.post(pack_url)\n    .header(CONTENT_TYPE, DIGEST_LIST_MEDIA_TYPE)\n    .body(body)\n    .send().await?;\nlet ct = resp.headers().get(CONTENT_TYPE).and_then(|v| v.to_str().ok());\nif ct.map(|c| !c.starts_with(BLOB_PACK_MEDIA_TYPE)).unwrap_or(true) {\n    bail!(\"endpoint returned non-pack content type: {:?}\", ct);\n}","typeGuard":null,"tryCatchPattern":"match client.get_blob_pack(&digests, staging).await {\n    Err(e) if e.to_string().contains(\"invalid content type\") => {\n        // proxy/server misconfiguration; fall back to per-blob downloads\n    }\n    other => other?,\n}","preventionTips":["Exclude the cache endpoints from auth proxies/CDNs that rewrite Content-Type","Add an integration test asserting the pack response Content-Type","Check response headers with curl -i after proxy or server config changes"],"tags":["remote-cache","content-type","http"],"backgroundTag":"unexpected-response-shape","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}