{"record":{"id":"e5bcd4eadaa18857","repo":"apache/dolphinscheduler","slug":"invalid-type-type","errorCode":null,"errorMessage":"invalid type : <type>","messagePattern":"invalid type : <type>","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/PluginType.java","lineNumber":65,"sourceCode":"    }\n\n    public boolean getHasUi() {\n        return hasUi;\n    }\n\n    private static HashMap<Integer, PluginType> PLUGIN_TYPE_MAP = new HashMap<>();\n\n    static {\n        for (PluginType pluginType : PluginType.values()) {\n            PLUGIN_TYPE_MAP.put(pluginType.getCode(), pluginType);\n        }\n    }\n\n    public static PluginType of(int type) {\n        if (PLUGIN_TYPE_MAP.containsKey(type)) {\n            return PLUGIN_TYPE_MAP.get(type);\n        }\n        throw new IllegalArgumentException(\"invalid type : \" + type);\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/PluginType.java#L47-L68","documentation":"PluginType.of(int) resolves a numeric plugin type code to the PluginType enum. It throws IllegalArgumentException when the type integer is not in PLUGIN_TYPE_MAP, i.e. the code does not correspond to any known plugin category (task, alert, datasource, etc.).","triggerScenarios":"Calling PluginType.of(type) with an int outside the set generated from the enum (values 0..N of known plugin categories), commonly when parsing plugin install/registry records or DB columns holding an invalid/legacy type code.","commonSituations":"Database rows written by an older DolphinScheduler version contain retired plugin type codes; custom code guesses a type number; plugin registration data corrupted or hand-edited.","solutions":["Log the invalid type value and use a named constant or PluginType.valueOf(name) instead of a hard-coded integer.","Check whether the data was produced by a different DolphinScheduler version and migrate/normalize the stored type codes.","Wrap the lookup in a try/catch (or containsKey check) and skip/flag unknown plugin types instead of failing the whole batch."],"exampleFix":"// before\nPluginType type = PluginType.of(pluginTypeCode); // throws on bad code\n\n// after\nint typeCode = pluginTypeCode;\nif (typeCode < 0 || typeCode >= PluginType.values().length) {\n    throw new IllegalArgumentException(\"Unknown plugin type code: \" + typeCode);\n}\nPluginType type = PluginType.of(typeCode);","handlingStrategy":"try-catch","validationCode":"boolean isValidPluginType(int type) {\n    return type >= 0 && type < PluginType.values().length;\n}","typeGuard":null,"tryCatchPattern":"try {\n    PluginType pt = PluginType.of(typeCode);\n    process(pt);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Skipping record with unknown plugin type {}: {}\", typeCode, e.getMessage());\n}","preventionTips":["Never hard-code plugin type numbers; reference PluginType enum constants.","Validate plugin type codes when importing/migrating registry or DB data.","Track plugin type code changes across DolphinScheduler upgrades."],"tags":["enum","plugin","validation"],"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"}