GoogleContainerTools/jib · error · IOException
IOException wrapping CompressorException while decompressing
Error message
IOException wrapping CompressorException while decompressing layer file
What it means
getDiffIdByDecompressingFile() computes a layer's diff ID by streaming the cached compressed file through Commons Compress' CompressorStreamFactory. If the stream is not a recognized compression format (GZIP, BZip2, XZ, etc.), CompressorException is thrown and wrapped in an IOException, which the Jib layer machinery surfaces to the user.
Source
Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageWriter.java:169
}
}
/**
* Decompresses the file to obtain the diff ID.
*
* @param compressedFile the file containing the compressed contents
* @return the digest of the decompressed file
* @throws IOException if an I/O exception occurs
*/
private static DescriptorDigest getDiffIdByDecompressingFile(Path compressedFile)
throws IOException {
try (InputStream in =
new CompressorStreamFactory(true)
.createCompressorInputStream(
new BufferedInputStream(Files.newInputStream(compressedFile)))) {
return Digests.computeDigest(in).getDigest();
} catch (CompressorException e) {
throw new IOException(e);
}
}
/**
* Writes a json template to the destination path by writing to a temporary file then moving the
* file.
*
* @param jsonTemplate the json template
* @param destination the destination path
* @throws IOException if an I/O exception occurs
*/
private static void writeJsonTemplate(JsonTemplate jsonTemplate, Path destination)
throws IOException {
Path temporaryFile = Files.createTempFile(destination.getParent(), null, null);
temporaryFile.toFile().deleteOnExit();
try (OutputStream outputStream = Files.newOutputStream(temporaryFile)) {
JsonTemplateMapper.writeTo(jsonTemplate, outputStream);
}View on GitHub (pinned to fb949e2676)
Solutions
- Delete the corrupted layer file (identified by the digest in the build log) and rebuild
- Clear the whole cache directory to re-download all layers
- Check disk space and filesystem health (truncation often indicates ENOSPC)
- Verify network/proxy stability if downloads keep being truncated
Example fix
// before: build fails reading layer sha256:abc // after rm -rf ~/.cache/google-cloud-tools-java/jib/layers/sha256:abc* mvn jib:build
Defensive patterns
Strategy: try-catch
Validate before calling
// Sanity-check gzip magic bytes before trusting a cached layer
byte[] hdr = new byte[2];
try (var in = Files.newInputStream(layerFile)) { in.readNBytes(hdr, 0, 2); }
if (hdr[0] != 0x1f || hdr[1] != (byte)0x8b) Files.deleteIfExists(layerFile); Try / catch
try {
build();
} catch (IOException e) {
if (e.getCause() instanceof CompressorException) {
deleteCorruptLayerFromCache();
build();
} else throw e;
} Prevention
- Check free disk space — truncation often means ENOSPC
- Use stable network/proxy settings for registry pulls
- Clear cache after disk errors or hard crashes
When it happens
Trigger: layerDiffId() calls getDiffIdByDecompressingFile() on a cached layer file whose bytes are not a valid compressed stream — corrupted/partial download, empty file, or a file saved without the expected compression.
Common situations: Truncated downloads from a flaky registry/network, cache files corrupted by disk errors or external tools, tar-layer flows where a non-compressed file is passed to the decompressor.
Related errors
- <exception message (IOException | CacheDirectoryCreationExce
- <exception message (IOException | CacheDirectoryCreationExce
- Unable to create cache directory for project path: ${path} -
- Cannot run Jib in offline mode; local Jib cache for base ima
- Cannot run Jib in offline mode; <imageReference> not found i
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/0cecc67523797bfd.
Report an issue: GitHub.