{"record":{"id":"cfcb206548c700da","repo":"apache/beam","slug":"unsupported-compression-type-canonical","errorCode":null,"errorMessage":"Unsupported compression type: \" + canonical","messagePattern":"Unsupported compression type: \" \\+ canonical","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileBasedSink.java","lineNumber":213,"sourceCode":"          throw new IllegalArgumentException(\"ZIP is unsupported\");\n\n        case ZSTD:\n          return ZSTD;\n\n        case LZO:\n          return LZO;\n\n        case LZOP:\n          return LZOP;\n\n        case DEFLATE:\n          return DEFLATE;\n\n        case SNAPPY:\n          return SNAPPY;\n\n        default:\n          throw new UnsupportedOperationException(\"Unsupported compression type: \" + canonical);\n      }\n    }\n  }\n\n  /**\n   * This is a helper function for turning a user-provided output filename prefix and converting it\n   * into a {@link ResourceId} for writing output files. See {@link TextIO.Write#to(String)} for an\n   * example use case.\n   *\n   * <p>Typically, the input prefix will be something like {@code /tmp/foo/bar}, and the user would\n   * like output files to be named as {@code /tmp/foo/bar-0-of-3.txt}. Thus, this function tries to\n   * interpret the provided string as a file {@link ResourceId} path.\n   *\n   * <p>However, this may fail, for example if the user gives a prefix that is a directory. E.g.,\n   * {@code /}, {@code gs://my-bucket}, or {@code c://}. In that case, interpreting the string as a\n   * file will fail and this function will return a directory {@link ResourceId} instead.\n   */\n  public static ResourceId convertToFileResourceIfPossible(String outputPrefix) {","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileBasedSink.java#L195-L231","documentation":"fromCanonical() throws UnsupportedOperationException when the Compression enum value has no mapping in the switch. This guards against future/unknown canonical types reaching the sink's compression translation.","triggerScenarios":"Passing a Compression value to FileBasedSink that is not one of UNCOMPRESSED, GZIP, BZIP2, ZIP, ZSTD, DEFLATE, or SNAPPY — typically from a newly added enum constant or a custom/unrecognized value.","commonSituations":"Version mismatches where a Compression constant exists in a newer SDK but this FileBasedSink switch does not handle it, or reflection/config-driven construction passing a bogus value.","solutions":["Upgrade the Beam SDK so the sink's switch handles your Compression value.","Set compression to a supported value (GZIP, BZIP2, ZSTD, SNAPPY, DEFLATE, or UNCOMPRESSED).","Check where the Compression value is constructed from config and constrain it to the supported set."],"exampleFix":"// before\nCompression c = Compression.valueOf(config.get(\"compression\")); // UNDEFINED\n// after\nCompression c = Compression.valueOf(config.getOrDefault(\"compression\", \"GZIP\"));","handlingStrategy":"validation","validationCode":"Set<Compression> supported = EnumSet.of(UNCOMPRESSED, GZIP, BZIP2, ZIP, ZSTD, DEFLATE, SNAPPY);\nif (!supported.contains(compression)) { throw new IllegalArgumentException(\"Compression not supported by this sink: \" + compression); }","typeGuard":null,"tryCatchPattern":"try { sink = buildSink(compression); } catch (UnsupportedOperationException e) { log.error(\"Unsupported compression {}\", compression, e); sink = buildSink(Compression.GZIP); }","preventionTips":["Pin all Beam SDK versions (client and runners) to the same release.","Derive Compression values from a whitelisted config enum."],"tags":["java","apache-beam","compression","unsupported-feature"],"backgroundTag":"unsupported-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}