{"record":{"id":"19abcfc5c7122216","repo":"apache/seatunnel","slug":"unknown-restore-mode-code","errorCode":null,"errorMessage":"Unknown restore mode code: ","messagePattern":"Unknown restore mode code: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-engine/seatunnel-engine-core/src/main/java/org/apache/seatunnel/engine/core/job/RestoreMode.java","lineNumber":59,"sourceCode":"    }\n\n    /** Returns the stable persisted and wire-level code for this restore mode. */\n    public int getCode() {\n        return code;\n    }\n\n    /**\n     * Resolves a stable persisted or wire-level code to its restore mode.\n     *\n     * @throws IllegalArgumentException if the code is unknown\n     */\n    public static RestoreMode fromCode(int code) {\n        for (RestoreMode restoreMode : values()) {\n            if (restoreMode.code == code) {\n                return restoreMode;\n            }\n        }\n        throw new IllegalArgumentException(\"Unknown restore mode code: \" + code);\n    }\n\n    /** Returns whether this mode requires checkpoint or savepoint state to be restored. */\n    public boolean isRestore() {\n        return this != NONE;\n    }\n}\n","sourceCodeStart":41,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-core/src/main/java/org/apache/seatunnel/engine/core/job/RestoreMode.java#L41-L67","documentation":"RestoreMode.fromCode maps an integer code to a RestoreMode enum value (NONE, DEFAULT, WAIT, etc.). If the code does not match any enum member, an IllegalArgumentException with 'Unknown restore mode code' is thrown. This protects against deserializing an unrecognized restore-mode code, often from newer/older binary versions.","triggerScenarios":"Calling RestoreMode.fromCode(code) with a code that is not one of the defined enum values; typically from deserialized job/checkpoint state, REST API input, or cross-version serialization where the enum set differs.","commonSituations":"Upgrading or downgrading SeaTunnel so a newer code is read by an older binary; a REST client posts a bogus restoreMode integer; state serialized with a custom code value.","solutions":["Use only codes present in RestoreMode.values() (check the enum source)","Ensure client and server SeaTunnel versions match so enum codes align","Replace raw int codes with the enum constant in caller code (RestoreMode.DEFAULT etc.)","Add a migration step to remap unknown codes from old state before deserialization"],"exampleFix":"// before\nRestoreMode mode = RestoreMode.fromCode(99); // throws\n// after\nRestoreMode mode = Arrays.stream(RestoreMode.values())\n        .filter(m -> m.getCode() == 99)\n        .findFirst()\n        .orElse(RestoreMode.DEFAULT);","handlingStrategy":"try-catch","validationCode":"boolean known = Arrays.stream(RestoreMode.values()).anyMatch(m -> m.getCode() == code);","typeGuard":"static Optional<RestoreMode> safeFromCode(int code) {\n    return Arrays.stream(RestoreMode.values())\n            .filter(m -> m.getCode() == code)\n            .findFirst();\n}","tryCatchPattern":"try {\n    mode = RestoreMode.fromCode(code);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Unknown restore mode code {}, falling back to DEFAULT\", code);\n    mode = RestoreMode.DEFAULT;\n}","preventionTips":["Never hardcode int codes; use enum constants","Keep SeaTunnel versions in sync across client/server","Validate deserialized codes against values() before use","Pin serialization schema versions"],"tags":["java","enum","serialization","version-compatibility"],"backgroundTag":"invalid-enum-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}