apache/druid · error · IllegalArgumentException
[ ] is not a valid gz file name
Error message
[%s] is not a valid gz file name
What it means
Thrown by CompressionUtils.getGzBaseName when the input filename does not pass isGz (does not end with the .gz suffix) or its name minus extension is empty. The method's job is to strip the .gz suffix to derive the base file name, so it validates the name is a gzip name first.
Solutions
- Check CompressionUtils.isGz(fname) before calling getGzBaseName and handle non-gz files separately.
- Correct the filename/extension of the source file.
- For mixed inputs, use CompressionUtils.decompress(in, fileName) which dispatches on extension instead of assuming gzip.
- Filter directory listings to *.gz files before deriving base names.
Example fix
// before
String base = CompressionUtils.getGzBaseName(fileName); // fileName = "data.zip"
// after
if (CompressionUtils.isGz(fileName)) {
String base = CompressionUtils.getGzBaseName(fileName);
} Defensive patterns
Strategy: validation
Validate before calling
if (fname == null || !fname.endsWith(".gz")
|| Files.getNameWithoutExtension(fname).isEmpty()) {
throw new IllegalArgumentException("Not a valid gz name: " + fname);
} Type guard
static boolean isValidGzName(String fname) {
return fname != null && CompressionUtils.isGz(fname)
&& !Files.getNameWithoutExtension(fname).isEmpty();
} Try / catch
try {
base = CompressionUtils.getGzBaseName(fname);
} catch (IllegalArgumentException e) {
// not a gz file; handle as uncompressed input
base = Files.getNameWithoutExtension(fname);
} Prevention
- Check isGz() before calling getGzBaseName
- Filter file listings to *.gz before deriving base names
- Use CompressionUtils.decompress() for extension-based dispatch on mixed inputs
- Beware of a file named just '.gz' which yields an empty base name
When it happens
Trigger: Calling getGzBaseName with a name like data.zip, data (no extension), or an empty string; also triggered by a file named only .gz whose reduced name is empty.
Common situations: Speculative decompression code calling getGzBaseName on every file in a directory without checking the extension first, firehose configs pointing at non-gz files, or copy-pasted filenames with wrong extensions.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- A local input source accepts only one of
- A local input source can set parameter
- A local input source requires one parameter of
- A local input source requires one property of
- A table definition must include a table spec.
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/40f38559c4822ae5.
Report an issue: GitHub.
Appendix: source
Thrown at processing/src/main/java/org/apache/druid/utils/CompressionUtils.java:790
return fName.endsWith(Format.GZ.getSuffix()) && fName.length() > Format.GZ.getSuffix().length();
}
/**
* Get the file name without the .gz extension
*
* @param fname The name of the gzip file
*
* @return fname without the ".gz" extension
*
* @throws IAE if fname is not a valid "*.gz" file name
*/
public static String getGzBaseName(String fname)
{
final String reducedFname = Files.getNameWithoutExtension(fname);
if (isGz(fname) && !reducedFname.isEmpty()) {
return reducedFname;
}
throw new IAE("[%s] is not a valid gz file name", fname);
}
/**
* Decompress an input stream from a file, based on the filename.
*/
public static InputStream decompress(final InputStream in, final String fileName) throws IOException
{
if (fileName.endsWith(Format.GZ.getSuffix())) {
return gzipInputStream(in);
} else if (fileName.endsWith(Format.LZ4.getSuffix())) {
return new LZ4BlockInputStream(in);
} else if (fileName.endsWith(Format.BZ2.getSuffix())) {
return new BZip2CompressorInputStream(in, true);
} else if (fileName.endsWith(Format.XZ.getSuffix())) {
return new XZCompressorInputStream(in, true);
} else if (fileName.endsWith(Format.SNAPPY.getSuffix())) {
return new FramedSnappyCompressorInputStream(in);
} else if (fileName.endsWith(Format.ZSTD.getSuffix())) {View on GitHub (pinned to 9b90983fd2)