{"record":{"id":"b2fecbc650e8ff52","repo":"apache/beam","slug":"unexpected-mode-mode","errorCode":null,"errorMessage":"Unexpected mode: \" + mode","messagePattern":"Unexpected mode: \" \\+ mode","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"warning","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileBasedSource.java","lineNumber":412,"sourceCode":"          System.currentTimeMillis() - startTime);\n      if (fileReaders.size() == 1) {\n        return fileReaders.get(0);\n      }\n      return new FilePatternReader(this, fileReaders);\n    } else {\n      return createSingleFileReader(options);\n    }\n  }\n\n  @Override\n  public String toString() {\n    switch (mode) {\n      case FILEPATTERN:\n        return fileOrPatternSpec.toString();\n      case SINGLE_FILE_OR_SUBRANGE:\n        return fileOrPatternSpec + \" range \" + super.toString();\n      default:\n        throw new IllegalStateException(\"Unexpected mode: \" + mode);\n    }\n  }\n\n  @Override\n  public void validate() {\n    super.validate();\n    switch (mode) {\n      case FILEPATTERN:\n        checkArgument(\n            getStartOffset() == 0,\n            \"FileBasedSource is based on a file pattern or a full single file \"\n                + \"but the starting offset proposed %s is not zero\",\n            getStartOffset());\n        checkArgument(\n            getEndOffset() == Long.MAX_VALUE,\n            \"FileBasedSource is based on a file pattern or a full single file \"\n                + \"but the ending offset proposed %s is not Long.MAX_VALUE\",\n            getEndOffset());","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileBasedSource.java#L394-L430","documentation":"FileBasedSource.toString() throws IllegalStateException when the source's Mode enum is neither FILEPATTERN nor SINGLE_FILE_OR_SUBRANGE. Since Mode has only these values, hitting this indicates internal state corruption or a new mode added without updating this switch.","triggerScenarios":"Calling toString() on a FileBasedSource whose mode field is an unexpected value — practically only via SDK version mismatch, deserialization of a foreign mode constant, or reflection.","commonSituations":"Debugging/logging a source object after SDK version skew between workers, or deserializing a pipeline graph serialized with a different Beam version.","solutions":["Ensure all workers and the submitting client use the same Beam SDK version.","Rebuild the pipeline and resubmit; clear stale serialized job graphs.","If you added a custom Mode constant, update toString()'s switch."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep Beam SDK versions consistent across client and workers.","Avoid deserializing pipeline graphs across Beam versions."],"tags":["java","apache-beam","internal-state","version-skew"],"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-14T16:17:12.679Z"}