{"record":{"id":"d9c0cdcdbee26908","repo":"apache/dolphinscheduler","slug":"invalid-code-d9c0cd","errorCode":null,"errorMessage":"invalid code : ","messagePattern":"invalid code : ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/RuleType.java","lineNumber":67,"sourceCode":"    }\n\n    public String getDescription() {\n        return description;\n    }\n\n    private static final Map<Integer, RuleType> VALUES_MAP = new HashMap<>();\n\n    static {\n        for (RuleType type : RuleType.values()) {\n            VALUES_MAP.put(type.code, type);\n        }\n    }\n\n    public static RuleType of(Integer status) {\n        if (VALUES_MAP.containsKey(status)) {\n            return VALUES_MAP.get(status);\n        }\n        throw new IllegalArgumentException(\"invalid code : \" + status);\n    }\n}\n","sourceCodeStart":49,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/RuleType.java#L49-L70","documentation":"RuleType.of(Integer) throws IllegalArgumentException when the given integer code is not a key in RuleType's VALUES_MAP of known rule-type codes. This is DolphinScheduler's guard against unmapped enum codes arriving from task parameters or persisted definitions. It means the caller passed a rule-type code this build of the library does not recognize.","triggerScenarios":"Calling RuleType.of(status) with null, or with an integer that is not one of the enum's defined codes (e.g. a code stored by a newer/older DolphinScheduler version, or a hand-edited task definition).","commonSituations":"Upgrading/downgrading DolphinScheduler so persisted rule-type codes no longer exist; copying a task definition JSON between environments; manually editing task params and typing a wrong rule type number; passing an uninitialized Integer field.","solutions":["Log/print the offending code and compare it against the codes defined in RuleType (the VALUES_MAP keys).","Fix the task definition/parameter so it uses a valid RuleType code from the running version.","If migrating across versions, re-map or re-save the workflow/task so codes are regenerated for the current version.","Guard call sites: check RuleType.contains(status) (or validate the code) before calling of()."],"exampleFix":"// before\nRuleType type = RuleType.of(params.getRuleType());\n// after\nInteger code = params.getRuleType();\nif (!RuleType.contains(code)) {\n    throw new IllegalArgumentException(\"Unsupported rule type code: \" + code);\n}\nRuleType type = RuleType.of(code);","handlingStrategy":"validation","validationCode":"if (code == null || !RuleType.contains(code)) {\n    throw new IllegalArgumentException(\"Unknown RuleType code: \" + code);\n}","typeGuard":"boolean isValidRuleType(Integer code) {\n    return code != null && RuleType.contains(code);\n}","tryCatchPattern":"try {\n    RuleType type = RuleType.of(code);\n} catch (IllegalArgumentException e) {\n    log.error(\"Unrecognized rule type code, falling back to default\", e);\n    RuleType type = RuleType.getDefault(); // or fail fast with a clear message\n}","preventionTips":["Always source rule-type codes from RuleType constants, never hard-coded literals.","When migrating DolphinScheduler versions, re-validate persisted task definitions against current enum codes.","Add a config-load-time validation step that resolves all rule-type codes before execution."],"tags":["enum","illegal-argument","task-configuration"],"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"}