jdx/mise · error

remote cache blob pack has an invalid digest algorithm

Error message

remote cache blob pack has an invalid digest algorithm

What it means

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.

Solutions

  1. Upgrade the client so it understands the algorithm IDs the server emits
  2. If the server introduced new algorithm IDs, pin the server to a format compatible with deployed clients
  3. Check for stream corruption if only some downloads fail — earlier framed_bytes/size checks would otherwise desync
  4. Reproduce with curl --raw to confirm whether the served bytes truly contain the bad ID
Defensive patterns

Strategy: fallback

Validate before calling

// When parsing pack framing yourself, whitelist algorithm IDs first:
let id = algorithm_byte;
if !matches!(id, 1 | 2) { bail!("unsupported pack algorithm id {id}"); }

Try / catch

match client.get_blob_pack(&digests, staging).await? {
    Some(pack) => use_pack(pack),
    None => {
        // decode unsupported — fetch blobs individually via get_blob/get_blob_file
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/ecd3eba56541065a. Report an issue: GitHub.

Appendix: source

Thrown at crates/mise-cache-core/src/lib.rs:811

    }

    let directory = tempfile::tempdir_in(staging_dir)?;
    let mut seen = BTreeSet::new();
    let mut blobs = Vec::new();
    let mut payload_bytes = 0_u64;
    let mut framed_bytes = BLOB_PACK_MAGIC.len() as u64;
    loop {
        let mut algorithm = [0_u8; 1];
        if reader.read(&mut algorithm).await? == 0 {
            break;
        }
        let (algorithm, mut hasher) = match algorithm[0] {
            1 => (
                "blake3",
                BlobPackHasher::Blake3(Box::new(blake3::Hasher::new())),
            ),
            2 => ("sha256", BlobPackHasher::Sha256(sha2::Sha256::new())),
            _ => bail!("remote cache blob pack has an invalid digest algorithm"),
        };
        let mut hash = [0_u8; 32];
        reader.read_exact(&mut hash).await?;
        let mut size = [0_u8; 8];
        reader.read_exact(&mut size).await?;
        let digest = CacheDigest {
            algorithm: algorithm.into(),
            hash: hex::encode(hash),
            size: u64::from_be_bytes(size),
        };
        if !requested.contains(&digest) {
            bail!("remote cache blob pack returned an unrequested digest");
        }
        if !seen.insert(digest.clone()) {
            bail!("remote cache blob pack returned a duplicate digest");
        }
        framed_bytes = framed_bytes
            .checked_add(BLOB_PACK_HEADER_BYTES)

View on GitHub (pinned to 533346cc37)