GoogleContainerTools/jib · error · CacheCorruptedException

Schema 2 manifests corrupted

Error message

Schema 2 manifests corrupted

What it means

CacheStorageReader.verifyImageMetadata validates cached image metadata against its manifest format. For a Schema 2 manifest, every manifest entry in the cache must reference a config blob; if any entry has no config, the cache metadata is declared corrupted and CacheCorruptedException is thrown. This guards against partially written or hand-edited cache directories producing unusable image metadata.

Source

Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageReader.java:66

    if (manifestsAndConfigs.isEmpty()) {
      throw new CacheCorruptedException(metadataCacheDirectory, "Manifest cache empty");
    }
    if (manifestsAndConfigs.stream().anyMatch(entry -> entry.getManifest() == null)) {
      throw new CacheCorruptedException(metadataCacheDirectory, "Manifest(s) missing");
    }
    if (metadata.getManifestList() == null && manifestsAndConfigs.size() != 1) {
      throw new CacheCorruptedException(metadataCacheDirectory, "Manifest list missing");
    }

    ManifestTemplate firstManifest = manifestsAndConfigs.get(0).getManifest();
    if (firstManifest instanceof V21ManifestTemplate) {
      if (metadata.getManifestList() != null
          || manifestsAndConfigs.stream().anyMatch(entry -> entry.getConfig() != null)) {
        throw new CacheCorruptedException(metadataCacheDirectory, "Schema 1 manifests corrupted");
      }
    } else if (firstManifest instanceof BuildableManifestTemplate) {
      if (manifestsAndConfigs.stream().anyMatch(entry -> entry.getConfig() == null)) {
        throw new CacheCorruptedException(metadataCacheDirectory, "Schema 2 manifests corrupted");
      }
      if (metadata.getManifestList() != null
          && manifestsAndConfigs.stream().anyMatch(entry -> entry.getManifestDigest() == null)) {
        throw new CacheCorruptedException(metadataCacheDirectory, "Schema 2 manifests corrupted");
      }
    } else {
      throw new CacheCorruptedException(
          metadataCacheDirectory, "Unknown manifest type: " + firstManifest);
    }
  }

  private final CacheStorageFiles cacheStorageFiles;

  CacheStorageReader(CacheStorageFiles cacheStorageFiles) {
    this.cacheStorageFiles = cacheStorageFiles;
  }

  /**

View on GitHub (pinned to fb949e2676)

Solutions

  1. Delete the Jib cache directory (default ~/.cache/google-cloud-tools-java/jib or jib.cacheDirectory setting) so it is rebuilt on the next build
  2. Run the build with a fresh cache by setting the <cache> / jib.cacheDirectory parameter to a new location
  3. Upgrade Jib in case an older version wrote cache entries in an incompatible layout
  4. Check for processes (antivirus, sync tools) that delete files from the cache directory

Example fix

// before (corrupted cache dir reused)
mvn package jib:build
// after (clear cache)
rm -rf ~/.cache/google-cloud-tools-java/jib
mvn package jib:build
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify manifest and configs exist before build
Files.list(cacheDir.resolve("manifests")).forEach(System.out::println);

Type guard

boolean isSchema2MetadataComplete(ImageMetadata m) {
  return m.getManifestList() == null ||
    m.getManifestsAndConfigs().stream().allMatch(e -> e.getConfig() != null);
}

Try / catch

try {
  jibBuild();
} catch (CacheCorruptedException e) {
  deleteRecursively(cacheDirectory);
  jibBuild(); // rebuild with fresh cache
}

Prevention

When it happens

Trigger: retrieveMetadata() -> verifyImageMetadata() finds a cached BuildableManifestTemplate (V22ManifestTemplate / OCI manifest) whose manifestsAndConfigs list contains an entry with getConfig() == null.

Common situations: Interrupted cache writes (JVM killed mid-write), manual deletion of config blob files under the cache directory, cache directories shared between Jib versions or corrupted by disk issues.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/695ded5ae5d0baa8. Report an issue: GitHub.