GoogleContainerTools/jib · error · CacheCorruptedException
Layer file did not include valid hash: <layerFile>
Error message
Layer file did not include valid hash: <layerFile>
What it means
Jib's cache stores layers as files whose filenames are the layer digest hashes. getDigestFromFilename parses the filename back into a DescriptorDigest; if the filename is not a valid hash, the cache is considered corrupted and CacheCorruptedException is thrown including the offending layer file path.
Source
Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageFiles.java:64
CacheStorageFiles(Path cacheDirectory) {
this.cacheDirectory = cacheDirectory;
}
/**
* Gets the diff ID portion of the layer filename.
*
* @param layerFile the layer file to parse for the diff ID
* @return the diff ID portion of the layer file filename
* @throws CacheCorruptedException if no valid diff ID could be parsed
*/
DescriptorDigest getDigestFromFilename(Path layerFile) throws CacheCorruptedException {
try {
String hash = layerFile.getFileName().toString();
return DescriptorDigest.fromHash(hash);
} catch (DigestException | IndexOutOfBoundsException ex) {
throw new CacheCorruptedException(
cacheDirectory, "Layer file did not include valid hash: " + layerFile, ex);
}
}
/**
* Gets the cache directory.
*
* @return the cache directory
*/
Path getCacheDirectory() {
return cacheDirectory;
}
/**
* Resolves the layer contents file.
*
* @param layerDigest the layer digest
* @param layerDiffId the layer diff IdView on GitHub (pinned to fb949e2676)
Solutions
- Delete the corrupted layer file (the path is in the error message) or the whole Jib cache directory and let Jib re-download it
- Run the build again with network access to repopulate the cache
- Avoid manually touching files in the Jib cache directory
- If corruption recurs, check disk health and disable aggressive cache-clearing tools
Example fix
// before: manually inspect/edit ~/.cache/google-cloud-tools-jib/layers/* // after rm -rf ~/.cache/google-cloud-tools-jib mvn jib:build // cache rebuilt cleanly
Defensive patterns
Strategy: fallback
Validate before calling
for f in ~/.cache/google-cloud-tools-jib/layers/*; do echo "$(basename $f)" | grep -qE '^[a-f0-9]{64}$' || rm -f "$f"; done Prevention
- Do not manually modify cache files
When it happens
Trigger: getDigestFromFilename encounters a layer file in the cache directory whose name fails DescriptorDigest.fromHash (wrong length, illegal characters, e.g. a filename without a valid sha256 hash) or an IndexOutOfBoundsException while splitting the hash.
Common situations: Manual edits or partial writes in the Jib cache directory (~/.cache/google-cloud-tools-jib); files copied between machines with mangled names; cache corruption after crashes or interrupted downloads; disk cleanup tools renaming/truncating files.
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
- Manifest cache empty
- Manifest(s) missing
- Manifest list missing
- Schema 1 manifests corrupted
- Expected valid layer digest as contents of selector file `<s
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/affa1b6f01e07334.
Report an issue: GitHub.