{"record":{"id":"d7001e3d5c6c9afc","repo":"apache/dolphinscheduler","slug":"invalid-code-d7001e","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/OptionSourceType.java","lineNumber":70,"sourceCode":"    }\n\n    public String getDescription() {\n        return description;\n    }\n\n    private static final Map<Integer, OptionSourceType> VALUES_MAP = new HashMap<>();\n\n    static {\n        for (OptionSourceType type : OptionSourceType.values()) {\n            VALUES_MAP.put(type.code, type);\n        }\n    }\n\n    public static OptionSourceType 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":52,"sourceCodeEnd":73,"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/OptionSourceType.java#L52-L73","documentation":"OptionSourceType.of(Integer) throws IllegalArgumentException when the given code is not in VALUES_MAP. OptionSourceType categorizes where a data-quality option value originates (e.g. fixed value vs from a dataset column); an unmapped code means the option source type in data-quality task parameters is not recognized by this build.","triggerScenarios":"Calling OptionSourceType.of() with an Integer missing from VALUES_MAP — typically when the options section of data-quality task parameters contains an unknown source type, or parameter templates written for another enum/version are reused.","commonSituations":"Hand-editing data-quality options JSON; API clients sending wrong numeric option source types; version skew between workflow definitions persisted earlier and the current enum definitions.","solutions":["Verify the option source type code in the data-quality parameters matches an OptionSourceType constant and fix it.","Use OptionSourceType enum constants when generating parameter JSON.","Re-map stored codes to current enum values after DolphinScheduler upgrades.","Validate the code against OptionSourceType's map before calling of() when the value comes from user input."],"exampleFix":"// before\nOptionSourceType sourceType = OptionSourceType.of(option.getInteger(\"sourceType\"));\n\n// after: null-safe with validation\nInteger code = option.getInteger(\"sourceType\");\nOptionSourceType sourceType = (code == null) ? OptionSourceType.DEFAULT\n        : OptionSourceType.of(code);","handlingStrategy":"validation","validationCode":"static boolean isKnownOptionSourceType(Integer code) {\n    return code != null && Arrays.stream(OptionSourceType.values()).anyMatch(t -> t.getCode().equals(code));\n}","typeGuard":"static Optional<OptionSourceType> safeOf(Integer status) {\n    if (status == null) return Optional.empty();\n    return Arrays.stream(OptionSourceType.values())\n            .filter(t -> t.getCode().equals(status))\n            .findFirst();\n}","tryCatchPattern":"try {\n    sourceType = OptionSourceType.of(code);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Unknown option source type {}, using default\", code);\n    sourceType = OptionSourceType.DEFAULT;\n}","preventionTips":["Build data-quality options JSON from enum constants instead of hand-written numbers.","Null-check sourceType fields before calling of().","Re-validate stored data-quality parameters after DolphinScheduler version changes.","Don't copy numeric code tables between the data-quality enums (OptionSourceType, InputType, etc.)."],"tags":["java","enum","data-quality","illegal-argument"],"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"}