apache/dolphinscheduler · error · IllegalArgumentException

invalid type : <type>

Error message

invalid type : <type>

What it means

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.).

Source

Thrown at dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/PluginType.java:65

    }

    public boolean getHasUi() {
        return hasUi;
    }

    private static HashMap<Integer, PluginType> PLUGIN_TYPE_MAP = new HashMap<>();

    static {
        for (PluginType pluginType : PluginType.values()) {
            PLUGIN_TYPE_MAP.put(pluginType.getCode(), pluginType);
        }
    }

    public static PluginType of(int type) {
        if (PLUGIN_TYPE_MAP.containsKey(type)) {
            return PLUGIN_TYPE_MAP.get(type);
        }
        throw new IllegalArgumentException("invalid type : " + type);
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Log the invalid type value and use a named constant or PluginType.valueOf(name) instead of a hard-coded integer.
  2. Check whether the data was produced by a different DolphinScheduler version and migrate/normalize the stored type codes.
  3. Wrap the lookup in a try/catch (or containsKey check) and skip/flag unknown plugin types instead of failing the whole batch.

Example fix

// before
PluginType type = PluginType.of(pluginTypeCode); // throws on bad code

// after
int typeCode = pluginTypeCode;
if (typeCode < 0 || typeCode >= PluginType.values().length) {
    throw new IllegalArgumentException("Unknown plugin type code: " + typeCode);
}
PluginType type = PluginType.of(typeCode);
Defensive patterns

Strategy: try-catch

Validate before calling

boolean isValidPluginType(int type) {
    return type >= 0 && type < PluginType.values().length;
}

Try / catch

try {
    PluginType pt = PluginType.of(typeCode);
    process(pt);
} catch (IllegalArgumentException e) {
    log.warn("Skipping record with unknown plugin type {}: {}", typeCode, e.getMessage());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/e5bcd4eadaa18857. Report an issue: GitHub.