{"record":{"id":"ad1d301bd7b7881f","repo":"apache/druid","slug":"directory-compression-not-supported-for-s","errorCode":null,"errorMessage":"Directory compression not supported for %s","messagePattern":"Directory compression not supported for (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/utils/CompressionUtils.java","lineNumber":180,"sourceCode":"      if (null == extension) {\n        return null;\n      }\n      return EXTENSION_TO_COMPRESSION_FORMAT.get(extension);\n    }\n\n    /**\n     * Compresses a directory to the output stream. Default implementation throws UnsupportedOperationException.\n     * Override this method for formats that support directory compression.\n     *\n     * @param directory The directory to compress\n     * @param out The output stream to write compressed data to\n     * @return The number of bytes (uncompressed) read from the input directory\n     * @throws IOException if an I/O error occurs\n     * @throws UnsupportedOperationException if the format doesn't support directory compression\n     */\n    public long compressDirectory(File directory, OutputStream out) throws IOException\n    {\n      throw new UnsupportedOperationException(\"Directory compression not supported for \" + this.name());\n    }\n\n    /**\n     * Decompresses a directory from the input stream. Default implementation throws UnsupportedOperationException.\n     * Override this method for formats that support directory decompression.\n     *\n     * @param in The input stream containing compressed data\n     * @param outDir The output directory to extract files to\n     * @return A FileCopyResult containing information about extracted files\n     * @throws IOException if an I/O error occurs\n     * @throws UnsupportedOperationException if the format doesn't support directory decompression\n     */\n    public FileUtils.FileCopyResult decompressDirectory(InputStream in, File outDir) throws IOException\n    {\n      throw new UnsupportedOperationException(\"Directory decompression not supported for \" + this.name());\n    }\n  }\n","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/utils/CompressionUtils.java#L162-L198","documentation":"CompressionUtils.CompressionFormat.compressDirectory is a default method that throws UnsupportedOperationException; only formats that actually support compressing a whole directory (e.g. gzip/tgz, zip) override it. Calling it on a format such as LZ4 or ZSTD (which support only stream compression via this default) throws this error. It is a deliberate capability gate, not a runtime failure.","triggerScenarios":"Calling compressDirectory on a CompressionFormat enum value whose directory-compression method was not overridden — e.g. format LZ4 or ZSTD in CompressionUtils — instead of using lz4CompressDirectory/zstdCompressDirectory or a supported format like GZIP/ZIP.","commonSituations":"Generic backup/job code that iterates formats and calls compressDirectory without checking support; config selecting a compression format that lacks directory support; newer formats added before the directory methods were implemented.","solutions":["Check format support before calling, e.g. switch on the format and use the dedicated lz4/zstd stream-compression helpers","Use a directory-capable format (GZIP/tgz or ZIP) when a whole directory must be compressed","Wrap the call in try/catch for UnsupportedOperationException and fall back to per-file compression","Confirm the Druid version's CompressionFormat overrides for your chosen format"],"exampleFix":"// before\nnew CompressionUtils.CompressionFormat.LZ4().compressDirectory(dir, out); // throws\n// after\nCompressionUtils.lz4CompressDirectory(dir, out); // dedicated stream compressor\n// or use GZIP: CompressionUtils.gzipDirectory? -> CompressionUtils.zip(dir, out);","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  format.compressDirectory(dir, out);\n} catch (UnsupportedOperationException e) {\n  // fall back to per-file compression or a supported format\n}","preventionTips":["Only call compressDirectory on GZIP/ZIP-style formats","Dispatch on the format enum explicitly instead of generic calls","Catch UnsupportedOperationException at the format-dispatch layer"],"tags":["java","unsupported-operation","compression","format-capability"],"backgroundTag":"unsupported-operation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}