{"record":{"id":"429ffb4bb406a3b6","repo":"jdx/mise","slug":"remote-cache-blob-failed-digest-verification","errorCode":null,"errorMessage":"remote cache blob failed digest verification","messagePattern":"remote cache blob failed digest verification","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mise-cache-core/src/lib.rs","lineNumber":673,"sourceCode":"    }\n\n    pub async fn get_blob(\n        &self,\n        digest: &CacheDigest,\n        media_type: &'static str,\n    ) -> Result<Vec<u8>> {\n        digest.validate()?;\n        let url = self.blob_endpoint(digest)?;\n        retry_async(\"GET\", &url, self.retries, || async {\n            let response = self\n                .request(reqwest::Method::GET, url.clone(), media_type)\n                .await?\n                .send()\n                .await?\n                .error_for_status()?;\n            let bytes = response.bytes().await?.to_vec();\n            if !digest.matches_bytes(&bytes)? {\n                bail!(\"remote cache blob failed digest verification\");\n            }\n            Ok(bytes)\n        })\n        .await\n    }\n\n    pub async fn get_blob_file(\n        &self,\n        digest: &CacheDigest,\n        staging_dir: &Path,\n    ) -> Result<tempfile::NamedTempFile> {\n        let url = self.blob_endpoint(digest)?;\n        let download = retry_async(\"GET\", &url, self.retries, || async {\n            let mut response = self\n                .request(reqwest::Method::GET, url.clone(), BLOB_MEDIA_TYPE)\n                .await?\n                .send()\n                .await?;","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/crates/mise-cache-core/src/lib.rs#L655-L691","documentation":"get_blob downloads a CAS blob into memory and verifies its bytes against the requested CacheDigest before returning them. If the downloaded content does not hash to the expected digest, the client bails rather than returning corrupted data. This catches truncated, tampered-with, or wrongly-keyed blobs from the server or an intermediary.","triggerScenarios":"Calling get_blob and receiving bytes whose blake3/sha256 (and size) do not match the digest in the request URL — including via retry_async, which will retry before surfacing the error.","commonSituations":"Bit-flipping network corruption (rare with TLS but possible via broken caches); a server that stored an object under the wrong key; an intermediary cache serving stale/truncated bodies; disk corruption on the cache server.","solutions":["Retry the fetch — transient corruption may resolve; the library already retries, so repeated failure indicates real corruption","Delete the corrupted blob from the remote cache and re-upload it (put_blob) from a trusted source","Check the cache server's storage health (disk errors, truncation)","If using a proxy, bypass it to determine whether the intermediary is serving bad bodies"],"exampleFix":"// caller-side re-upload repair\nmatch client.get_blob(&digest, BLOB_MEDIA_TYPE).await {\n    Err(e) if e.to_string().contains(\"digest verification\") => {\n    client.put_blob(&BlobUpload { digest: digest.clone(), source: BlobSource::Bytes(good_bytes) }).await?;\n    }\n    ok => ok?,\n}","handlingStrategy":"retry","validationCode":"// Caller can verify after receipt as a second line of defense:\nlet bytes = client.get_blob(&digest, media_type).await?;\nassert!(digest.matches_bytes(&bytes)?, \"blob failed local verification\");","typeGuard":null,"tryCatchPattern":"let bytes = loop {\n    match client.get_blob(&digest, BLOB_MEDIA_TYPE).await {\n        Ok(b) => break b,\n        Err(e) if e.to_string().contains(\"digest verification\") && attempts < 3 => { attempts += 1; }\n        Err(e) => return Err(e),\n    }\n};","preventionTips":["Repair pipelines: on verification failure, delete and re-upload the blob from a trusted source","Monitor the cache server's disks and storage backend health","Avoid intermediaries that can truncate or transform response bodies"],"tags":["remote-cache","integrity","checksum"],"backgroundTag":"checksum-mismatch","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"}