{"record":{"id":"b7e1cbb571f1315d","repo":"apache/dolphinscheduler","slug":"invalid-code-b7e1cb","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/ConnectorType.java","lineNumber":63,"sourceCode":"    }\n\n    public String getDescription() {\n        return description;\n    }\n\n    private static final Map<Integer, ConnectorType> VALUES_MAP = new HashMap<>();\n\n    static {\n        for (ConnectorType type : ConnectorType.values()) {\n            VALUES_MAP.put(type.code, type);\n        }\n    }\n\n    public static ConnectorType 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":45,"sourceCodeEnd":66,"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/ConnectorType.java#L45-L66","documentation":"ConnectorType.of(Integer) throws IllegalArgumentException when the supplied code is not a key of the enum's VALUES_MAP. ConnectorType enumerates the data-source/datasource connector types used by the data-quality module; an unmapped code indicates the connector type passed in task params or via the API is not defined.","triggerScenarios":"Calling ConnectorType.of() with an Integer not registered in VALUES_MAP — e.g. data-quality task parameters carry an unknown or out-of-range connector type, or a caller passes a database type code from a different enum.","commonSituations":"Configuring data-quality jobs against a newly added datasource type whose code the running data-quality version does not know; hand-editing job parameter JSON; version skew where stored workflow definitions reference removed connector codes.","solutions":["Verify the connector type code in the data-quality task parameters matches a ConnectorType constant and correct it.","Reference the enum constant (ConnectorType.MYSQL etc.) instead of a raw integer in code.","Align the DolphinScheduler data-quality module version with the version that produced the stored parameters.","Catch IllegalArgumentException when parsing external input and report the invalid code to the user."],"exampleFix":"// before\nConnectorType connector = ConnectorType.of(typeCode);\n\n// after: tolerate unknown codes\nConnectorType connector = Arrays.stream(ConnectorType.values())\n        .filter(t -> t.getCode().equals(typeCode))\n        .findFirst()\n        .orElseThrow(() -> new IllegalArgumentException(\"Unsupported connector type: \" + typeCode));","handlingStrategy":"validation","validationCode":"static boolean isKnownConnectorType(Integer code) {\n    return code != null && Arrays.stream(ConnectorType.values()).anyMatch(t -> t.getCode().equals(code));\n}","typeGuard":"static Optional<ConnectorType> safeOf(Integer status) {\n    if (status == null) return Optional.empty();\n    return Arrays.stream(ConnectorType.values())\n            .filter(t -> t.getCode().equals(status))\n            .findFirst();\n}","tryCatchPattern":"try {\n    connector = ConnectorType.of(code);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Datasource connector type not supported by this build: \" + code, e);\n}","preventionTips":["Ensure the datasource type is registered in the running build before wiring data-quality jobs to it.","Use ConnectorType enum constants rather than hardcoded type codes.","Keep API/plugin versions aligned so connector codes match between writer and reader.","Validate connector type codes at parameter-generation time, not at execution time."],"tags":["java","enum","data-quality","connector"],"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"}