{"record":{"id":"13dd17b721bee7ab","repo":"apache/dolphinscheduler","slug":"invalid-code-13dd17","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/OperatorType.java","lineNumber":71,"sourceCode":"    }\n\n    public String getDescription() {\n        return description;\n    }\n\n    private static final Map<Integer, OperatorType> VALUES_MAP = new HashMap<>();\n\n    static {\n        for (OperatorType type : OperatorType.values()) {\n            VALUES_MAP.put(type.code, type);\n        }\n    }\n\n    public static OperatorType 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":53,"sourceCodeEnd":74,"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/OperatorType.java#L53-L74","documentation":"OperatorType.of(Integer) throws IllegalArgumentException when the given code is not present in VALUES_MAP. OperatorType enumerates comparison operators used in data-quality check rules (e.g. equals, greater-than); an unmapped code means a rule references an operator this build does not define.","triggerScenarios":"Calling OperatorType.of() with an Integer absent from VALUES_MAP — typically when a data-quality rule's operator field in task parameters holds an unknown value, codes were copied from another enum, or stored rules predate an enum change.","commonSituations":"Authoring data-quality comparison rules by hand; exporting/importing workflows between DolphinScheduler versions with different operator codes; frontend/API writing operator indices that no longer match backend enum order.","solutions":["Check the operator code in the data-quality rule parameters against OperatorType constants and correct it.","Use OperatorType enum constants instead of raw integers when building rules.","Remap persisted rule codes after upgrading DolphinScheduler.","Catch IllegalArgumentException when loading external rules and skip/report the invalid rule."],"exampleFix":"// before\nOperatorType op = OperatorType.of(rule.getOperator());\n\n// after: defensive parsing\nOperatorType op = Arrays.stream(OperatorType.values())\n        .filter(o -> o.getCode().equals(rule.getOperator()))\n        .findFirst()\n        .orElseThrow(() -> new IllegalArgumentException(\"Unknown operator code in rule \" + rule.getName()));","handlingStrategy":"validation","validationCode":"static boolean isKnownOperatorType(Integer code) {\n    return code != null && Arrays.stream(OperatorType.values()).anyMatch(t -> t.getCode().equals(code));\n}","typeGuard":"static Optional<OperatorType> safeOf(Integer status) {\n    if (status == null) return Optional.empty();\n    return Arrays.stream(OperatorType.values())\n            .filter(t -> t.getCode().equals(status))\n            .findFirst();\n}","tryCatchPattern":"try {\n    op = OperatorType.of(code);\n} catch (IllegalArgumentException e) {\n    log.error(\"Rule references unknown operator {}\", code);\n    throw new IllegalStateException(\"Data-quality rule has invalid operator code: \" + code, e);\n}","preventionTips":["Define comparison rules with OperatorType constants; never rely on enum ordinal positions.","Validate operator codes on the frontend before submitting rules to the API.","After upgrades, scan persisted rules for codes absent from the current OperatorType.","Keep backend enum and UI operator list generated from the same source."],"tags":["java","enum","data-quality","operator"],"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-14T05:17:10.506Z"}