{"record":{"id":"affa1b6f01e07334","repo":"GoogleContainerTools/jib","slug":"layer-file-did-not-include-valid-hash-layerfile","errorCode":null,"errorMessage":"Layer file did not include valid hash: <layerFile>","messagePattern":"Layer file did not include valid hash: <layerFile>","errorType":"exception","errorClass":"CacheCorruptedException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageFiles.java","lineNumber":64,"sourceCode":"\n  CacheStorageFiles(Path cacheDirectory) {\n    this.cacheDirectory = cacheDirectory;\n  }\n\n  /**\n   * Gets the diff ID portion of the layer filename.\n   *\n   * @param layerFile the layer file to parse for the diff ID\n   * @return the diff ID portion of the layer file filename\n   * @throws CacheCorruptedException if no valid diff ID could be parsed\n   */\n  DescriptorDigest getDigestFromFilename(Path layerFile) throws CacheCorruptedException {\n    try {\n      String hash = layerFile.getFileName().toString();\n      return DescriptorDigest.fromHash(hash);\n\n    } catch (DigestException | IndexOutOfBoundsException ex) {\n      throw new CacheCorruptedException(\n          cacheDirectory, \"Layer file did not include valid hash: \" + layerFile, ex);\n    }\n  }\n\n  /**\n   * Gets the cache directory.\n   *\n   * @return the cache directory\n   */\n  Path getCacheDirectory() {\n    return cacheDirectory;\n  }\n\n  /**\n   * Resolves the layer contents file.\n   *\n   * @param layerDigest the layer digest\n   * @param layerDiffId the layer diff Id","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageFiles.java#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: manually inspect/edit ~/.cache/google-cloud-tools-jib/layers/*\n// after\nrm -rf ~/.cache/google-cloud-tools-jib\nmvn jib:build   // cache rebuilt cleanly","handlingStrategy":"fallback","validationCode":"for f in ~/.cache/google-cloud-tools-jib/layers/*; do echo \"$(basename $f)\" | grep -qE '^[a-f0-9]{64}$' || rm -f \"$f\"; done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not manually modify cache files"],"tags":["cache","corruption","digest","jib"],"backgroundTag":"checksum-mismatch","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}