{"record":{"id":"661efb363e094f92","repo":"apache/flink","slug":"incompatible-version-found-compatible-version","errorCode":null,"errorMessage":"Incompatible version: found {}, compatible versions are {}","messagePattern":"Incompatible version: found (.+?), compatible versions are (.+?)","errorType":"exception","errorClass":"VersionMismatchException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/io/VersionedIOReadableWritable.java","lineNumber":100,"sourceCode":"        for (int compatibleVersion : compatibleVersions) {\n            if (compatibleVersion == readVersion) {\n                return;\n            }\n        }\n\n        String error =\n                \"Incompatible version: found \"\n                        + readVersion\n                        + \", compatible versions are \"\n                        + Arrays.toString(compatibleVersions);\n\n        Optional<String> incompatibleVersionError =\n                getAdditionalDetailsForIncompatibleVersion(readVersion);\n        if (incompatibleVersionError.isPresent()) {\n            error += \". \" + incompatibleVersionError.get();\n        }\n\n        throw new VersionMismatchException(error);\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/io/VersionedIOReadableWritable.java#L82-L103","documentation":"Thrown as a VersionMismatchException by VersionedIOReadableWritable.resolveVersionRead when the version integer read from the stream does not appear in the getCompatibleVersions() array. By default only the current getVersion() is compatible, but subclasses can widen this. This guard prevents deserializing data written by an incompatible serialization version, which could produce corrupt objects.","triggerScenarios":"Reading serialized data whose embedded version is not in the compatible set; data written by a newer Flink version read by an older one; data written by a different serializer implementation altogether.","commonSituations":"Downgrading Flink and restoring a checkpoint/savepoint written by a newer version; cross-version state incompatibility; serializer refactoring that changed the version number without adding backward compatibility.","solutions":["Check the Flink version that wrote the data against the version reading it; upgrade rather than downgrade if versions diverge.","If you control the serializer subclass, override getCompatibleVersions() to include the older version.","Override getAdditionalDetailsForIncompatibleVersion to provide migration guidance.","If incompatible, discard the old state and re-create from a fresh savepoint."],"exampleFix":"// before — only current version accepted\n@Override public int[] getCompatibleVersions() { return new int[]{getVersion()}; }\n\n// after — accept legacy versions\n@Override public int[] getCompatibleVersions() { return new int[]{getVersion(), 1, 2}; }","handlingStrategy":"validation","validationCode":"int[] compatible = obj.getCompatibleVersions();\nboolean ok = false;\nfor (int v : compatible) if (v == expectedReadVersion) { ok = true; break; }\nif (!ok) throw new VersionMismatchException(\"Version \" + expectedReadVersion + \" not compatible\");","typeGuard":null,"tryCatchPattern":"try {\n    obj.read(in);\n} catch (VersionMismatchException e) {\n    // check for downgrade incompatibility; upgrade or re-create state\n}","preventionTips":["Avoid downgrading Flink versions when restoring checkpoints.","When evolving a serializer, add old versions to getCompatibleVersions().","Provide migration guidance via getAdditionalDetailsForIncompatibleVersion()."],"tags":["serialization","version-mismatch","checkpoint-restore","versioned-io"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}