{"record":{"id":"3a73e2495e4b7a59","repo":"apache/druid","slug":"directory-decompression-not-supported-for-s","errorCode":null,"errorMessage":"Directory decompression not supported for %s","messagePattern":"Directory decompression not supported for (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/utils/CompressionUtils.java","lineNumber":195,"sourceCode":"     */\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\n  public static final int COMPRESSED_TEXT_WEIGHT_FACTOR = 4;\n  private static final Logger log = new Logger(CompressionUtils.class);\n  private static final int DEFAULT_RETRY_COUNT = 3;\n  private static final int GZIP_BUFFER_SIZE = 8192; // Default is 512\n\n  /**\n   * Zip the contents of directory into the file indicated by outputZipFile. Sub directories are skipped\n   *\n   * @param directory     The directory whose contents should be added to the zip in the output stream.\n   * @param outputZipFile The output file to write the zipped data to\n   * @param fsync         True if the output file should be fsynced to disk\n   *\n   * @return The number of bytes (uncompressed) read from the input directory.\n   *\n   * @throws IOException","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/utils/CompressionUtils.java#L177-L213","documentation":"The CompressionFormat.decompressDirectory default method throws UnsupportedOperationException because not every format can decompress a whole directory stream; only formats with directory support (gzip/tgz, zip) override it. Calling it on a stream-compression-only format such as LZ4 or ZSTD throws this error. Use the format-specific decompression helpers instead.","triggerScenarios":"Calling decompressDirectory on a CompressionFormat like LZ4 or ZSTD, or generically dispatching decompression over formats without checking which override decompressDirectory.","commonSituations":"Restore/load jobs that decompress whatever format a config names; archives written by a stream compressor being fed to decompressDirectory; version drift where a format lacks the directory override.","solutions":["Use the format-specific decompression path, e.g. CompressionUtils.decompress with a LZ4 InputStream factory, for stream-only formats","Restrict directory decompression to GZIP/ZIP formats and validate the configured format beforehand","Catch UnsupportedOperationException and fall back to stream decompression into the target directory","Check the CompressionFormat implementation for your Druid version to confirm directory support"],"exampleFix":"// before\nformat.decompressDirectory(in, outDir); // throws for LZ4/ZSTD\n// after\nif (format == CompressionUtils.CompressionFormat.LZ4) {\n  CompressionUtils.decompress(in, outDir, CompressionUtils.LZ4_STREAM_FACTORY);\n} else {\n  format.decompressDirectory(in, outDir);\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  format.decompressDirectory(in, outDir);\n} catch (UnsupportedOperationException e) {\n  CompressionUtils.decompress(in, outDir, format-specificFactory);\n}","preventionTips":["Use stream decompression helpers for LZ4/ZSTD","Validate the configured format supports directory operations before jobs run","Centralize format dispatch with capability checks"],"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"}