apache/beam · error · IllegalArgumentException
Unsupported compression type: " + compression
Error message
Unsupported compression type: " + compression
What it means
CompressedSource.CompressionMode.fromCanonical converts a canonical Compression enum into a CompressionMode; an unrecognized value means the switch has no mapping (unknown enum constant, typically from a version mismatch or corrupted value). It throws IllegalArgumentException naming the offending compression.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/io/CompressedSource.java:170
return ZIP;
case ZSTD:
return ZSTD;
case LZO:
return LZO;
case LZOP:
return LZOP;
case DEFLATE:
return DEFLATE;
case SNAPPY:
return SNAPPY;
default:
throw new IllegalArgumentException("Unsupported compression type: " + compression);
}
}
}
private final FileBasedSource<T> sourceDelegate;
private final DecompressingChannelFactory channelFactory;
/**
* Creates a {@code CompressedSource} from an underlying {@code FileBasedSource}. The type of
* compression used will be based on the file name extension unless explicitly configured via
* {@link CompressedSource#withDecompression}.
*/
public static <T> CompressedSource<T> from(FileBasedSource<T> sourceDelegate) {
return new CompressedSource<>(sourceDelegate, CompressionMode.AUTO);
}
/**
* Return a {@code CompressedSource} that is like this one but will decompress its underlying fileView on GitHub (pinned to 12126d8942)
Solutions
- Align all Beam SDK jars to a single version so the enum constant exists.
- Use only compression types supported by the deployed Beam version's Compression enum.
- Check the switch coverage in CompressedSource.java for your Beam version and pick a mapped value.
Example fix
// before Compression mode = Compression.ZSTD; // not present in deployed Beam version CompressedSource.CompressionMode.fromCanonical(mode); // after Compression mode = Compression.GZIP; // supported by the deployed version
Defensive patterns
Strategy: try-catch
Validate before calling
Set<String> supported = Set.of("GZIP","BZIP2","ZIP","DEFLATE","SNAPPY");
if (!supported.contains(compression.name())) throw new IllegalArgumentException("unsupported compression: " + compression); Try / catch
try {
mode = CompressedSource.CompressionMode.fromCanonical(canonical);
} catch (IllegalArgumentException e) {
mode = CompressedSource.CompressionMode.GZIP;
} Prevention
- Pin all Beam SDK modules to one version
- Use only enum constants defined by the deployed Beam version
- Avoid serializing Compression enums across SDK versions
When it happens
Trigger: Passing a Compression value to CompressedSource.CompressionMode.fromCanonical that is not GZIP, BZIP2, ZIP, DEF late, or SNAPPY per the switch in that Beam version — e.g., a newer/older enum constant like ZSTD when running against an older Beam jar.
Common situations: Mixing Beam SDK versions on the classpath; referencing an enum constant added after the deployed Beam version; reflection-based or serialized enum values crossing versions.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- AUTO is not supported for writing
- Failed to determine if the source is splittable
- Must resolve compression into a concrete value before callin
- AUTO is applicable only to reading files
- Writing ZIP files is currently unsupported
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/9ce5583676526b79.
Report an issue: GitHub.