{"record":{"id":"5cd686a97461051c","repo":"apache/beam","slug":"writing-zip-files-is-currently-unsupported","errorCode":null,"errorMessage":"Writing ZIP files is currently unsupported","messagePattern":"Writing ZIP files is currently unsupported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/io/Compression.java","lineNumber":133,"sourceCode":"\n    @Override\n    public WritableByteChannel writeCompressed(WritableByteChannel channel) throws IOException {\n      return Channels.newChannel(\n          new BZip2CompressorOutputStream(Channels.newOutputStream(channel)));\n    }\n  },\n\n  /** Zip compression. */\n  ZIP(\".zip\", \".zip\") {\n    @Override\n    public ReadableByteChannel readDecompressed(ReadableByteChannel channel) throws IOException {\n      FullZipInputStream zip = new FullZipInputStream(Channels.newInputStream(channel));\n      return Channels.newChannel(zip);\n    }\n\n    @Override\n    public WritableByteChannel writeCompressed(WritableByteChannel channel) throws IOException {\n      throw new UnsupportedOperationException(\"Writing ZIP files is currently unsupported\");\n    }\n  },\n\n  /**\n   * ZStandard compression.\n   *\n   * <p>The {@code .zst} extension is specified in <a href=https://tools.ietf.org/html/rfc8478>RFC\n   * 8478</a>.\n   *\n   * <p>The Beam Java SDK does not pull in the Zstd library by default, so it is the user's\n   * responsibility to declare an explicit dependency on {@code zstd-jni}. Attempts to read or write\n   * .zst files without {@code zstd-jni} loaded will result in {@code NoClassDefFoundError} at\n   * runtime.\n   */\n  ZSTD(\".zst\", \".zst\", \".zstd\") {\n    @Override\n    public ReadableByteChannel readDecompressed(ReadableByteChannel channel) throws IOException {\n      return Channels.newChannel(new ZstdCompressorInputStream(Channels.newInputStream(channel)));","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/io/Compression.java#L115-L151","documentation":"Beam can read ZIP-compressed inputs (via FullZipInputStream) but has no ZIP writer; the ZIP variant of writeCompressed() unconditionally throws UnsupportedOperationException. Writing ZIP output is simply not implemented.","triggerScenarios":"Configuring an output sink with ZIP compression, e.g., FileIO.write().withCompression(Compression.ZIP) or TextIO sinks whose compression resolves to ZIP.","commonSituations":"Users assuming read/write symmetry across compression types; config templates that set zip for all IO; migrating gzip outputs to zip without checking support.","solutions":["Write with a supported compression (GZIP, BZIP2, or ZSTD) instead of ZIP.","Write UNCOMPRESSED output and compress externally in a downstream job step if ZIP is mandatory.","Add a custom sink wrapper that compresses output bytes into a zip archive yourself."],"exampleFix":"// before\n.withCompression(Compression.ZIP)\n// after\n.withCompression(Compression.GZIP)","handlingStrategy":"validation","validationCode":"if (compression == Compression.ZIP) {\n  throw new IllegalArgumentException(\"ZIP output unsupported; use GZIP/BZIP2/ZSTD\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  out = compression.writeCompressed(channel);\n} catch (UnsupportedOperationException e) {\n  out = Compression.GZIP.writeCompressed(channel);\n}","preventionTips":["Use GZIP/BZIP2/ZSTD for compressed outputs","Compress ZIP archives in a downstream step if ZIP is mandatory","Check the Compression enum docs for read-only entries"],"tags":["java","io","compression","zip","unsupported-operation"],"backgroundTag":"operation-not-supported","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}