{"record":{"id":"2181a028afc04eba","repo":"apache/beam","slug":"unknown-mode-s-for-avrosource-s","errorCode":null,"errorMessage":"Unknown mode %s for AvroSource %s","messagePattern":"Unknown mode (.+?) for AvroSource (.+?)","errorType":"exception","errorClass":"InvalidObjectException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/io/AvroSource.java","lineNumber":566,"sourceCode":"    schema = parser.parse(schemaString);\n    schemaLogicalReferenceCache.put(schemaString, schema);\n    return schema;\n  }\n\n  // Reading the object from Java serialization typically does not go through the constructor,\n  // we use readResolve to replace the constructed instance with one which uses the constructor\n  // allowing us to intern any schemas.\n  @SuppressWarnings(\"unused\")\n  private Object readResolve() throws ObjectStreamException {\n    switch (getMode()) {\n      case SINGLE_FILE_OR_SUBRANGE:\n        return new AvroSource<>(\n            getSingleFileMetadata(), getMinBundleSize(), getStartOffset(), getEndOffset(), mode);\n      case FILEPATTERN:\n        return new AvroSource<>(\n            getFileOrPatternSpecProvider(), getEmptyMatchTreatment(), getMinBundleSize(), mode);\n      default:\n        throw new InvalidObjectException(\n            String.format(\"Unknown mode %s for AvroSource %s\", getMode(), this));\n    }\n  }\n\n  /**\n   * A {@link Block} of Avro records.\n   *\n   * @param <T> The type of records stored in the block.\n   */\n  static class AvroBlock<T> extends Block<T> {\n\n    // The current record in the block. Initialized in readNextRecord.\n    private @Nullable T currentRecord;\n\n    // The index of the current record in the block.\n    private long currentRecordIndex = 0;\n\n    private final Iterator<?> iterator;","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/io/AvroSource.java#L548-L584","documentation":"AvroSource's Java serialization readResolve validates that the persisted mode enum is one of the supported values (SINGLEFILE or FILEPATTERN). An unknown mode means deserialized state is inconsistent, so it throws InvalidObjectException.","triggerScenarios":"Deserializing an AvroSource whose serialized mode field holds a value not in the Mode enum — only possible across incompatible Beam versions or hand-corrupted serialized source state.","commonSituations":"Pipeline state (e.g. cached source objects or job graphs) serialized by one Beam version and deserialized by another after the Mode enum changed.","solutions":["Rebuild the pipeline with a single consistent Beam SDK version","Re-create the AvroSource instead of deserializing stale state","Clear caches of serialized pipeline artifacts produced by an older Beam version"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { ObjectInputStream in = ...; AvroSource<?> s = (AvroSource<?>) in.readObject(); } catch (InvalidObjectException e) { /* rebuild source from spec */ }","preventionTips":["Keep Beam SDK versions consistent across pipeline build and run environments","Avoid persisting serialized Beam source objects across upgrades","Reconstruct sources from AvroIO specs instead of caching serialized instances"],"tags":["serialization","avro","deserialization"],"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-20T03:17:13.778Z"}