{"record":{"id":"bc70172e360ad680","repo":"apache/dolphinscheduler","slug":"invalid-state-value-value","errorCode":null,"errorMessage":"Invalid State value: + value","messagePattern":"Invalid State value: \\+ value","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/model/SerialCommandDto.java","lineNumber":115,"sourceCode":"\n        // If the workflow instance is finished, then we directly delete the item from the queue\n        // so there are no finished state here\n        WAITING(0),\n        LAUNCHED(1),\n        ;\n        private final int value;\n\n        State(int value) {\n            this.value = value;\n        }\n\n        public static State of(int value) {\n            for (State state : values()) {\n                if (state.value == value) {\n                    return state;\n                }\n            }\n            throw new IllegalArgumentException(\"Invalid State value: \" + value);\n        }\n    }\n\n}\n","sourceCodeStart":97,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/model/SerialCommandDto.java#L97-L120","documentation":"The nested State enum in SerialCommandDto exposes State.of(int) which maps an integer flag value to a State constant; if no constant matches, it throws IllegalArgumentException with the offending value. This guards the deserialization of serialized command state fields against out-of-range or unknown values.","triggerScenarios":"Deserializing a serial-waiting/serial-running command whose encoded state int is not one of the defined State values — e.g. reading corrupted or hand-edited queue/command data, or code built against a different enum version than the data.","commonSituations":"Upgraded/older DolphinScheduler nodes exchanging serialized commands with different State mappings; manually modified DB rows or queue payloads; bug in the code writing the state int.","solutions":["Log/inspect the offending integer and compare it with the defined State values in SerialCommandDto.","Ensure all cluster nodes run the same version so the enum mapping matches.","Fix the producer that wrote the invalid state value.","If the value is externally supplied, validate it with State.of() inside a try-catch before use."],"exampleFix":"// before\nState state = State.of(rawValue); // throws if unknown\n// after\nState state;\ntry {\n    state = State.of(rawValue);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Unknown state {}, defaulting\", rawValue);\n    state = State.DEFAULT;\n}","handlingStrategy":"try-catch","validationCode":"boolean isValidState(int v) {\n    for (State s : State.values()) { if (s.value == v) return true; }\n    return false;\n}","typeGuard":"State tryOf(int v) {\n    for (State s : State.values()) { if (s.value == v) return s; }\n    return null;\n}","tryCatchPattern":"try {\n    state = State.of(value);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Unknown State value {}\", value);\n    state = fallbackState;\n}","preventionTips":["Keep enum ordinal/value mappings stable across versions.","Validate state ints read from external storage before mapping.","Run mixed-version compatibility tests before cluster upgrades."],"tags":["enum","deserialization","state"],"backgroundTag":"invalid-enum-value","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}