{"record":{"id":"f00a842be3534bab","repo":"apache/beam","slug":"unknown-directorytreatment-directorytreatment","errorCode":null,"errorMessage":"Unknown DirectoryTreatment: \" + directoryTreatment","messagePattern":"Unknown DirectoryTreatment: \" \\+ directoryTreatment","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java","lineNumber":878,"sourceCode":"    /**\n     * @return True if metadata is a directory and directory Treatment is SKIP.\n     * @throws java.lang.IllegalArgumentException if metadata is a directory and directoryTreatment\n     *     is Prohibited.\n     * @throws java.lang.UnsupportedOperationException if metadata is a directory and\n     *     directoryTreatment is not SKIP or PROHIBIT.\n     */\n    static boolean shouldSkipDirectory(\n        MatchResult.Metadata metadata, DirectoryTreatment directoryTreatment) {\n      if (metadata.resourceId().isDirectory()) {\n        switch (directoryTreatment) {\n          case SKIP:\n            return true;\n          case PROHIBIT:\n            throw new IllegalArgumentException(\n                \"Trying to read \" + metadata.resourceId() + \" which is a directory\");\n\n          default:\n            throw new UnsupportedOperationException(\n                \"Unknown DirectoryTreatment: \" + directoryTreatment);\n        }\n      }\n\n      return false;\n    }\n\n    /**\n     * Converts metadata to readableFile. Make sure {@link\n     * #shouldSkipDirectory(org.apache.beam.sdk.io.fs.MatchResult.Metadata,\n     * org.apache.beam.sdk.io.FileIO.ReadMatches.DirectoryTreatment)} returns false before using.\n     */\n    static ReadableFile matchToReadableFile(\n        MatchResult.Metadata metadata, Compression compression) {\n\n      compression =\n          (compression == Compression.AUTO)\n              ? Compression.detect(metadata.resourceId().getFilename())","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java#L860-L896","documentation":"FileIO's directory-treatment switch encountered a DirectoryTreatment value it does not recognize. This is an internal invariant violation: the enum should only contain SKIP, PROHIBIT, or ALLOW, so the default branch indicates a newly added enum constant without matching handling, or corrupted state.","triggerScenarios":"Calling FileIO read/match transforms whose configured DirectoryTreatment falls through the switch in shouldSkipDirectory — practically only possible if a new DirectoryTreatment constant was added to the enum without updating shouldSkipDirectory, or via binary-incompatible mixing of Beam versions.","commonSituations":"Mixing Beam jars of different versions on the classpath where one version added an enum constant; shading/relocation issues; custom code constructing the enum reflectively.","solutions":["Upgrade or align all Beam modules to the same version so enum and switch match","Check the classpath for duplicate/mixed org.apache.beam artifacts (mvn dependency:tree)","If you added a new DirectoryTreatment constant, add a case for it in shouldSkipDirectory"],"exampleFix":"// before\ncase ALLOW:\n  return false;\ndefault:\n  throw new UnsupportedOperationException(\"Unknown DirectoryTreatment: \" + directoryTreatment);\n// after\n// align beam-sdks-java-core version across all modules, or:\ncase NEW_TREATMENT:\n  return /* new behavior */ false;","handlingStrategy":"validation","validationCode":"// Ensure enum and handling stay in sync: exhaustiveness via switching without default\nswitch (directoryTreatment) {\n  case SKIP: case PROHIBIT: case ALLOW: break;\n  default: throw new IllegalStateException(\"Unhandled: \" + directoryTreatment);\n}","typeGuard":"boolean isKnownTreatment(DirectoryTreatment t) {\n  return t == DirectoryTreatment.SKIP\n      || t == DirectoryTreatment.PROHIBIT\n      || t == DirectoryTreatment.ALLOW;\n}","tryCatchPattern":"try {\n  fileIOTransform.expand(input);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Unknown DirectoryTreatment\")) {\n    throw new IllegalStateException(\"Beam version mismatch on DirectoryTreatment\", e);\n  }\n  throw e;\n}","preventionTips":["Keep all org.apache.beam artifacts at the same version","Run enforcer plugin rules to ban mixed Beam versions","Add a unit test covering every DirectoryTreatment constant","Avoid constructing enums reflectively"],"tags":["java","apache-beam","file-io","enum","unsupported-operation"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}