{"record":{"id":"0c090bac094fea48","repo":"apache/dolphinscheduler","slug":"invalid-code-0c090b","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/DataType.java","lineNumber":70,"sourceCode":"    }\n\n    public String getDescription() {\n        return description;\n    }\n\n    private static final Map<Integer, DataType> DATA_TYPE_MAP = new HashMap<>();\n\n    static {\n        for (DataType type : DataType.values()) {\n            DATA_TYPE_MAP.put(type.code, type);\n        }\n    }\n\n    public static DataType of(Integer status) {\n        if (DATA_TYPE_MAP.containsKey(status)) {\n            return DATA_TYPE_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/DataType.java#L52-L73","documentation":"DataType.of(Integer) throws IllegalArgumentException when the supplied code is not found in DATA_TYPE_MAP. DataType enumerates column/value data types (e.g. VARCHAR, INT) used by data-quality task parameters; an unmapped code means a data type code in the parameters is not one this build recognizes.","triggerScenarios":"Calling DataType.of() with an Integer missing from DATA_TYPE_MAP — typically when a data-quality task's parameter JSON carries an unknown data type code, or code tables from another enum/version are used to populate it.","commonSituations":"Building data-quality comparison rules where writer and reader map column types differently; DolphinScheduler upgrades changing DataType codes; hand-written parameter templates with wrong type codes.","solutions":["Check the dataType code in the data-quality task parameters against the DataType constants and fix it.","Use DataType enum constants when generating parameters instead of raw ints.","If definitions were exported from another DolphinScheduler version, re-map stored codes to the current DataType codes.","Validate the code is present in DataType's map before calling of()."],"exampleFix":"// before\nDataType dataType = DataType.of(code);\n\n// after: safe parse\nDataType dataType = code == null ? DataType.VARCHAR : DataType.of(code);","handlingStrategy":"validation","validationCode":"static boolean isKnownDataType(Integer code) {\n    return code != null && Arrays.stream(DataType.values()).anyMatch(t -> t.getCode().equals(code));\n}","typeGuard":"static Optional<DataType> safeOf(Integer status) {\n    if (status == null) return Optional.empty();\n    return Arrays.stream(DataType.values())\n            .filter(t -> t.getCode().equals(status))\n            .findFirst();\n}","tryCatchPattern":"try {\n    dataType = DataType.of(code);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Unknown data type code {}, defaulting to VARCHAR\", code);\n    dataType = DataType.VARCHAR;\n}","preventionTips":["Map column types to DataType via the enum's own mapping helpers, not ad-hoc integers.","Null-check type codes parsed from parameter JSON before conversion.","Re-validate persisted data-quality rules after upgrading DolphinScheduler.","Keep frontend type pickers and backend DataType codes in sync."],"tags":["java","enum","data-quality","data-type"],"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"}