{"record":{"id":"0cecc67523797bfd","repo":"GoogleContainerTools/jib","slug":"ioexception-wrapping-compressorexception-while-dec","errorCode":null,"errorMessage":"IOException wrapping CompressorException while decompressing layer file","messagePattern":"IOException wrapping CompressorException while decompressing layer file","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageWriter.java","lineNumber":169,"sourceCode":"    }\n  }\n\n  /**\n   * Decompresses the file to obtain the diff ID.\n   *\n   * @param compressedFile the file containing the compressed contents\n   * @return the digest of the decompressed file\n   * @throws IOException if an I/O exception occurs\n   */\n  private static DescriptorDigest getDiffIdByDecompressingFile(Path compressedFile)\n      throws IOException {\n    try (InputStream in =\n        new CompressorStreamFactory(true)\n            .createCompressorInputStream(\n                new BufferedInputStream(Files.newInputStream(compressedFile)))) {\n      return Digests.computeDigest(in).getDigest();\n    } catch (CompressorException e) {\n      throw new IOException(e);\n    }\n  }\n\n  /**\n   * Writes a json template to the destination path by writing to a temporary file then moving the\n   * file.\n   *\n   * @param jsonTemplate the json template\n   * @param destination the destination path\n   * @throws IOException if an I/O exception occurs\n   */\n  private static void writeJsonTemplate(JsonTemplate jsonTemplate, Path destination)\n      throws IOException {\n    Path temporaryFile = Files.createTempFile(destination.getParent(), null, null);\n    temporaryFile.toFile().deleteOnExit();\n    try (OutputStream outputStream = Files.newOutputStream(temporaryFile)) {\n      JsonTemplateMapper.writeTo(jsonTemplate, outputStream);\n    }","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageWriter.java#L151-L187","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: build fails reading layer sha256:abc\n// after\nrm -rf ~/.cache/google-cloud-tools-java/jib/layers/sha256:abc*\nmvn jib:build","handlingStrategy":"try-catch","validationCode":"// Sanity-check gzip magic bytes before trusting a cached layer\nbyte[] hdr = new byte[2];\ntry (var in = Files.newInputStream(layerFile)) { in.readNBytes(hdr, 0, 2); }\nif (hdr[0] != 0x1f || hdr[1] != (byte)0x8b) Files.deleteIfExists(layerFile);","typeGuard":null,"tryCatchPattern":"try {\n  build();\n} catch (IOException e) {\n  if (e.getCause() instanceof CompressorException) {\n    deleteCorruptLayerFromCache();\n    build();\n  } else throw e;\n}","preventionTips":["Check free disk space — truncation often means ENOSPC","Use stable network/proxy settings for registry pulls","Clear cache after disk errors or hard crashes"],"tags":["cache","compression","io"],"backgroundTag":"unsupported-compression-format","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}