{"record":{"id":"e6c6650a3cf34e37","repo":"GoogleContainerTools/jib","slug":"manifest-cache-empty","errorCode":null,"errorMessage":"Manifest cache empty","messagePattern":"Manifest cache empty","errorType":"exception","errorClass":"CacheCorruptedException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageReader.java","lineNumber":49,"sourceCode":"import java.io.IOException;\nimport java.nio.charset.StandardCharsets;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.security.DigestException;\nimport java.util.List;\nimport java.util.Optional;\nimport java.util.stream.Collectors;\nimport java.util.stream.Stream;\n\n/** Reads from the default cache storage engine. */\nclass CacheStorageReader {\n\n  @VisibleForTesting\n  static void verifyImageMetadata(ImageMetadataTemplate metadata, Path metadataCacheDirectory)\n      throws CacheCorruptedException {\n    List<ManifestAndConfigTemplate> manifestsAndConfigs = metadata.getManifestsAndConfigs();\n    if (manifestsAndConfigs.isEmpty()) {\n      throw new CacheCorruptedException(metadataCacheDirectory, \"Manifest cache empty\");\n    }\n    if (manifestsAndConfigs.stream().anyMatch(entry -> entry.getManifest() == null)) {\n      throw new CacheCorruptedException(metadataCacheDirectory, \"Manifest(s) missing\");\n    }\n    if (metadata.getManifestList() == null && manifestsAndConfigs.size() != 1) {\n      throw new CacheCorruptedException(metadataCacheDirectory, \"Manifest list missing\");\n    }\n\n    ManifestTemplate firstManifest = manifestsAndConfigs.get(0).getManifest();\n    if (firstManifest instanceof V21ManifestTemplate) {\n      if (metadata.getManifestList() != null\n          || manifestsAndConfigs.stream().anyMatch(entry -> entry.getConfig() != null)) {\n        throw new CacheCorruptedException(metadataCacheDirectory, \"Schema 1 manifests corrupted\");\n      }\n    } else if (firstManifest instanceof BuildableManifestTemplate) {\n      if (manifestsAndConfigs.stream().anyMatch(entry -> entry.getConfig() == null)) {\n        throw new CacheCorruptedException(metadataCacheDirectory, \"Schema 2 manifests corrupted\");\n      }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageReader.java#L31-L67","documentation":"When reading cached base-image metadata, verifyImageMetadata validates the stored ImageMetadataTemplate. If the list of manifests-and-configs is completely empty, the cache entry is incomplete, so CacheCorruptedException('Manifest cache empty') is thrown to force a fresh fetch rather than building from empty metadata.","triggerScenarios":"retrieveMetadata loads the metadata cache file for the base image and the deserialized manifestsAndConfigs list has size 0 — i.e., the cache file exists but contains no manifest entries (truncated/blank/invalid write).","commonSituations":"Interrupted previous build that wrote a partial metadata cache; manually deleted/edited cache files; cache migration between Jib versions producing empty entries; corrupted cache on a shared/ephemeral CI volume.","solutions":["Delete the Jib cache directory (or the specific image metadata directory) and rebuild online so metadata is re-fetched","Run the build once without offline mode to refresh the metadata cache","Check the metadata JSON files under the cache for truncation if the issue persists","Pin a stable Jib version so cache format expectations match what was written"],"exampleFix":"// before\nmvn jib:build -Djib.offline=true   // empty metadata cache\n// after\nrm -rf ~/.cache/google-cloud-tools-jib\nmvn jib:build    // online rebuild repopulates cache, then offline works","handlingStrategy":"retry","validationCode":"jq -e '.manifestsAndConfigs | length > 0' \"$METADATA_FILE\" || rm -f \"$METADATA_FILE\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Repair cache with an online build after interruptions"],"tags":["cache","corruption","metadata","jib"],"backgroundTag":"empty-result-set","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"}