jdx/mise · error
cached OCI layer size mismatch
Error message
cached OCI layer size mismatch
What it means
When mise rebuilds an OCI image from a cached layer (read_cached_layer in src/oci/layer/cache.rs:126), it verifies the cached blob file matches the size recorded in the cache metadata. This error means the layer blob on disk has a byte length different from the `size` field of the CachedLayer record — i.e. the cache is corrupt, truncated, or was written by a different/incomplete download.
Solutions
- Clear the OCI layer cache so it is repopulated: delete the cache directory mise used (e.g. under ~/.cache/mise OCI cache) and re-run the build/push.
- Re-run the operation that populated the cache while online so the layer is re-downloaded and re-verified.
- Check disk health/free space — truncation often indicates a full disk or fs corruption; fix that before re-caching.
- If you copy cache dirs, use a checksum-verifying method (rsync --checksum) instead of plain copies.
Example fix
// shell fix # before: build fails with size mismatch rm -rf ~/.cache/mise/oci # after: cache rebuilt mise build-push ... # re-downloads and revalidates layers
Defensive patterns
Strategy: fallback
Validate before calling
let meta = std::fs::metadata(blob_path)?;
if meta.len() != expected_size {
eprintln!("cache entry invalid; clearing");
std::fs::remove_file(blob_path)?;
} Try / catch
match read_cached_layer(...) {
Err(e) if e.to_string().contains("size mismatch") => {
invalidate_cache_entry(digest);
fetch_layer_fresh(digest)
}
other => other,
} Prevention
- Don't interrupt cache-populating operations; ensure adequate disk space
- Never hand-edit or prune files inside the OCI cache directory
- Use checksum-verified copies (rsync --checksum) when sharing caches
When it happens
Trigger: Calling read_cached_layer (via build_cached_tool_layer) where the file at cache_dir/<digest> exists but its length != record.size. Typical causes: an interrupted cache write, disk corruption or truncation, manual edits/deletions inside the OCI cache directory, or a stale record pointing at an overwritten blob.
Common situations: A tool cache populated by a killed process or full disk; sharing an OCI cache directory between machines/versions with rsync that skipped or truncated files; manually pruning files in the cache; filesystem corruption after a crash.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- cached OCI layer diff ID mismatch
- cached OCI layer digest mismatch
- base image has layers in its manifest but diff_ids in its…
- base image has layers in its manifest but diff_ids in its…
- blob digest mismatch: got
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/4ed086b3c50fa100.
Report an issue: GitHub.
Appendix: source
Thrown at src/oci/layer/cache.rs:126
Ok(hex_encode(&hash.finalize()))
}
fn field(hash: &mut Sha256, bytes: &[u8]) {
hash.update((bytes.len() as u64).to_le_bytes());
hash.update(bytes);
}
fn read_cached_layer(record_path: &Path, cache_dir: &Path) -> Result<Option<LayerBlob>> {
let record = match std::fs::read(record_path) {
Ok(bytes) => bytes,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),
Err(err) => return Err(err.into()),
};
let record: CachedLayer = serde_json::from_slice(&record)?;
crate::oci::layout::validate_sha256_digest(&record.digest)?;
crate::oci::layout::validate_sha256_digest(&record.diff_id)?;
let bytes = std::fs::read(cache_dir.join(record.digest.trim_start_matches("sha256:")))?;
eyre::ensure!(
bytes.len() as u64 == record.size,
"cached OCI layer size mismatch"
);
let digest = format!("sha256:{}", hex_encode(&Sha256::digest(&bytes)));
eyre::ensure!(digest == record.digest, "cached OCI layer digest mismatch");
let mut decoder = flate2::read::GzDecoder::new(bytes.as_slice());
let mut hash = Sha256::new();
let mut buffer = [0; 64 * 1024];
loop {
let n = decoder.read(&mut buffer)?;
if n == 0 {
break;
}
hash.update(&buffer[..n]);
}
let diff_id = format!("sha256:{}", hex_encode(&hash.finalize()));
eyre::ensure!(
diff_id == record.diff_id,View on GitHub (pinned to 533346cc37)