{"record":{"id":"bd438acd6a03b54e","repo":"apache/iceberg","slug":"unknown-read-version-readversion-bd438a","errorCode":null,"errorMessage":"Unknown read version: \" + readVersion","messagePattern":"Unknown read version: \" \\+ readVersion","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/SortKeySerializer.java","lineNumber":358,"sourceCode":"      Preconditions.checkState(sortOrder != null, \"Invalid sort order: null\");\n\n      StringUtils.writeString(SchemaParser.toJson(schema), out);\n      StringUtils.writeString(SortOrderParser.toJson(sortOrder), out);\n    }\n\n    @Override\n    public void readSnapshot(int readVersion, DataInputView in, ClassLoader userCodeClassLoader)\n        throws IOException {\n      switch (readVersion) {\n        case 1:\n          read(in);\n          this.version = 1;\n          break;\n        case 2:\n          read(in);\n          break;\n        default:\n          throw new IllegalArgumentException(\"Unknown read version: \" + readVersion);\n      }\n    }\n\n    @Override\n    public TypeSerializerSchemaCompatibility<SortKey> resolveSchemaCompatibility(\n        TypeSerializerSnapshot<SortKey> oldSerializerSnapshot) {\n      if (!(oldSerializerSnapshot instanceof SortKeySerializerSnapshot)) {\n        return TypeSerializerSchemaCompatibility.incompatible();\n      }\n\n      if (oldSerializerSnapshot.getCurrentVersion() == 1 && this.getCurrentVersion() == 2) {\n        return TypeSerializerSchemaCompatibility.compatibleAfterMigration();\n      }\n\n      // Sort order should be identical\n      SortKeySerializerSnapshot oldSnapshot = (SortKeySerializerSnapshot) oldSerializerSnapshot;\n      if (!sortOrder.sameOrder(oldSnapshot.sortOrder)) {\n        return TypeSerializerSchemaCompatibility.incompatible();","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/shuffle/SortKeySerializer.java#L340-L376","documentation":"SortKeySerializer's snapshot wrapper (readSnapshot) throws IllegalArgumentException when the serialized serializer-snapshot format version is neither 1 nor 2. The wrapper only knows how to restore versions 1 (readSnapshotPreamble) and 2 (read); a higher or unknown version means the bytes were written by a different Iceberg release.","triggerScenarios":"Restoring operator state whose SortKeySerializerSnapshot was written with an unknown version number — typically a savepoint/checkpoint from a newer Iceberg version being read by an older one, or corrupted state where the version int is wrong.","commonSituations":"Downgrading Iceberg after taking a savepoint; restoring a savepoint into a cluster with an older connector jar; byte corruption in checkpoint metadata.","solutions":["Restore the savepoint with an Iceberg version >= the one that wrote it (upgrade iceberg-flink-runtime, never downgrade past the writer's version).","Take a fresh savepoint with the target version, then stop the old-version state usage.","Verify no duplicate iceberg jars on the classpath causing the wrong snapshot reader to load.","If the version int looks absurd (huge/negative), treat the checkpoint as corrupted and restart from a fresh savepoint."],"exampleFix":"// before: old jar reading v3 snapshot\n// after: upgrade dependency\n// implementation 'org.apache.iceberg:iceberg-flink-runtime-1.20:<matching-or-newer-version>'","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  snapshot.read(in);\n} catch (IllegalArgumentException e) {\n  throw new IllegalStateException(\n      \"Serializer snapshot version newer than this Iceberg version; upgrade\", e);\n}","preventionTips":["Never downgrade Iceberg below the version that wrote the savepoint","Record the Iceberg version in savepoint metadata","Upgrade iceberg-flink-runtime before restoring state"],"tags":["flink","serializer-snapshot","savepoint","version-compatibility"],"backgroundTag":"invalid-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}