{"record":{"id":"ecd3eba56541065a","repo":"jdx/mise","slug":"remote-cache-blob-pack-has-an-invalid-digest-algor","errorCode":null,"errorMessage":"remote cache blob pack has an invalid digest algorithm","messagePattern":"remote cache blob pack has an invalid digest algorithm","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mise-cache-core/src/lib.rs","lineNumber":811,"sourceCode":"    }\n\n    let directory = tempfile::tempdir_in(staging_dir)?;\n    let mut seen = BTreeSet::new();\n    let mut blobs = Vec::new();\n    let mut payload_bytes = 0_u64;\n    let mut framed_bytes = BLOB_PACK_MAGIC.len() as u64;\n    loop {\n        let mut algorithm = [0_u8; 1];\n        if reader.read(&mut algorithm).await? == 0 {\n            break;\n        }\n        let (algorithm, mut hasher) = match algorithm[0] {\n            1 => (\n                \"blake3\",\n                BlobPackHasher::Blake3(Box::new(blake3::Hasher::new())),\n            ),\n            2 => (\"sha256\", BlobPackHasher::Sha256(sha2::Sha256::new())),\n            _ => bail!(\"remote cache blob pack has an invalid digest algorithm\"),\n        };\n        let mut hash = [0_u8; 32];\n        reader.read_exact(&mut hash).await?;\n        let mut size = [0_u8; 8];\n        reader.read_exact(&mut size).await?;\n        let digest = CacheDigest {\n            algorithm: algorithm.into(),\n            hash: hex::encode(hash),\n            size: u64::from_be_bytes(size),\n        };\n        if !requested.contains(&digest) {\n            bail!(\"remote cache blob pack returned an unrequested digest\");\n        }\n        if !seen.insert(digest.clone()) {\n            bail!(\"remote cache blob pack returned a duplicate digest\");\n        }\n        framed_bytes = framed_bytes\n            .checked_add(BLOB_PACK_HEADER_BYTES)","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/crates/mise-cache-core/src/lib.rs#L793-L829","documentation":"Each framed entry in a blob pack starts with a one-byte digest-algorithm identifier; only 1 (blake3) and 2 (sha256) are defined. Any other byte means the pack was produced by an incompatible/newer encoder, and the client bails. This is a strict forward-compatibility guard on the pack framing format.","triggerScenarios":"Decoding a blob pack (via get_blob_pack) whose entry framing contains an unrecognized algorithm byte — e.g. a server writing algorithm id 3 for a digest type this client doesn't know, or bit corruption shifting the framing.","commonSituations":"Server upgraded to a pack format with new algorithm IDs while the client is older; framing desync from a corrupted stream causing a payload byte to be read as the algorithm byte; hand-crafted or test packs with invalid IDs.","solutions":["Upgrade the client so it understands the algorithm IDs the server emits","If the server introduced new algorithm IDs, pin the server to a format compatible with deployed clients","Check for stream corruption if only some downloads fail — earlier framed_bytes/size checks would otherwise desync","Reproduce with curl --raw to confirm whether the served bytes truly contain the bad ID"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// When parsing pack framing yourself, whitelist algorithm IDs first:\nlet id = algorithm_byte;\nif !matches!(id, 1 | 2) { bail!(\"unsupported pack algorithm id {id}\"); }","typeGuard":null,"tryCatchPattern":"match client.get_blob_pack(&digests, staging).await? {\n    Some(pack) => use_pack(pack),\n    None => {\n        // decode unsupported — fetch blobs individually via get_blob/get_blob_file\n    }\n}","preventionTips":["Upgrade clients before the server starts emitting new algorithm IDs","Never hand-craft pack streams; generate them only with the library's encoder","Investigate stream corruption if the bad ID appears sporadically (framing desync)"],"tags":["remote-cache","blob-pack","algorithm","framing"],"backgroundTag":"invalid-enum-value","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"}