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

Thrown inside decode_blob_pack's record loop (crates/mise-cache-core/src/lib.rs:918): each blob record starts with a 1-byte algorithm tag — 1 maps to blake3, 2 maps to sha256 — and any other byte bails with this error. The tag selects the hasher used to verify the record's subsequent 32-byte hash and 8-byte big-endian size, so an unknown tag means the record cannot be verified or interpreted.

Source

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

    }

    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 6f52dcdf99)

Solutions

  1. Align client and server versions so both understand the same algorithm tag set (v1: 1=blake3, 2=sha256)
  2. If you operate the server, only emit tag 1 or 2 per record for this protocol version
  3. If corruption is suspected, disable blob packs to fall back to per-blob GETs where each blob is independently digest-verified and resync is impossible to misalign
  4. Capture and hex-dump the offending pack to check whether the stream is merely misaligned (earlier record's size wrong) rather than a genuinely new tag
Defensive patterns

Strategy: fallback

Try / catch

match client.get_blob_pack(&digests, &staging).await {
    Err(e) if e.to_string().contains("invalid digest algorithm") => {
        client.disable_blob_packs();
        fallback_per_blob(&client, &digests) // each blob digest-verified independently
    }
    other => other?,
}

Prevention

When it happens

Trigger: A blob pack body whose per-record algorithm byte is not 0x01 or 0x02 — e.g. a newer pack format that added algorithm tags (sha512 = 3?), a hand-crafted pack with the wrong tag, or byte-stream corruption/desynchronization where the reader is misaligned and reads a hash byte as the tag (usually preceded by other symptoms).

Common situations: Version skew after a pack format extension; a custom server writing tags this decoder predates; stream desync caused by an earlier record with a wrong size field — the loop then reads mid-record bytes as the next tag; corrupted bodies in transit.

Related errors


AI-assisted analysis of jdx/mise@6f52dcdf99 (2026-08-22). Data as JSON: /api/errors/ecd3eba56541065a. Report an issue: GitHub.