jdx/mise · error

remote cache blob pack has invalid magic

Error message

remote cache blob pack has invalid magic

What it means

decode_blob_pack reads the blob-pack stream and expects it to begin with the fixed BLOB_PACK_MAGIC bytes. If the leading bytes don't match, the payload is not a valid blob pack and the client bails. This detects proxies/HTML error pages, wrong endpoints, or format-version mismatches masquerading as a 200 pack response.

Solutions

  1. Capture the response body (curl --raw) and inspect the leading bytes
  2. Confirm the server's pack format version matches the client's expected magic; upgrade whichever side lags
  3. Bypass intermediaries to rule out body rewriting
  4. As a workaround, let blob packs fail once — get_blob_pack disables packs after a hard error path and callers fall back to single-blob downloads
Defensive patterns

Strategy: fallback

Validate before calling

// Peek the first bytes of a pack response yourself before decoding:
let mut magic = [0u8; MAGIC.len()];
reader.read_exact(&mut magic).await?;
if &magic != BLOB_PACK_MAGIC { bail!("not a blob pack"); }

Try / catch

match client.get_blob_pack(&digests, staging).await? {
    Some(pack) => use_pack(pack),
    None => {
        // packs unavailable/failed handshake — fetch each digest via get_blob/get_blob_file
    }
}

Prevention

When it happens

Trigger: POSTing to blobs:pack and receiving a 200 response with correct Content-Type but a body that does not start with the pack magic — e.g. an intercepted response, a server-side format change, or a completely different binary format.

Common situations: Transparent proxies rewriting bodies; server upgraded to an incompatible pack format; a server bug writing the wrong framing header; response body corruption.

Related errors


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

Appendix: source

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

    let item_units = digests.len().div_ceil(BLOB_PACK_TIMEOUT_ITEMS_PER_UNIT);
    let item_units = u64::try_from(item_units).unwrap_or(u64::MAX);
    let multiplier = byte_units.max(item_units).max(1);
    base.saturating_mul(u32::try_from(multiplier).unwrap_or(u32::MAX))
}

async fn decode_blob_pack(
    response: reqwest::Response,
    requested: &[CacheDigest],
    staging_dir: &Path,
) -> Result<DownloadedBlobPack> {
    let metadata = BlobPackResponseMetadata::from_headers(response.headers())?;
    let requested = requested.iter().cloned().collect::<BTreeSet<_>>();
    let stream = response.bytes_stream().map_err(std::io::Error::other);
    let mut reader = tokio_util::io::StreamReader::new(stream);
    let mut magic = [0_u8; BLOB_PACK_MAGIC.len()];
    reader.read_exact(&mut magic).await?;
    if &magic != BLOB_PACK_MAGIC {
        bail!("remote cache blob pack has invalid magic");
    }

    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())),

View on GitHub (pinned to 533346cc37)