apache/dolphinscheduler · error · IllegalArgumentException

invalid code :

Error message

invalid code : 

What it means

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.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ConnectorType.java:63

    }

    public String getDescription() {
        return description;
    }

    private static final Map<Integer, ConnectorType> VALUES_MAP = new HashMap<>();

    static {
        for (ConnectorType type : ConnectorType.values()) {
            VALUES_MAP.put(type.code, type);
        }
    }

    public static ConnectorType of(Integer status) {
        if (VALUES_MAP.containsKey(status)) {
            return VALUES_MAP.get(status);
        }
        throw new IllegalArgumentException("invalid code : " + status);
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Verify the connector type code in the data-quality task parameters matches a ConnectorType constant and correct it.
  2. Reference the enum constant (ConnectorType.MYSQL etc.) instead of a raw integer in code.
  3. Align the DolphinScheduler data-quality module version with the version that produced the stored parameters.
  4. Catch IllegalArgumentException when parsing external input and report the invalid code to the user.

Example fix

// before
ConnectorType connector = ConnectorType.of(typeCode);

// after: tolerate unknown codes
ConnectorType connector = Arrays.stream(ConnectorType.values())
        .filter(t -> t.getCode().equals(typeCode))
        .findFirst()
        .orElseThrow(() -> new IllegalArgumentException("Unsupported connector type: " + typeCode));
Defensive patterns

Strategy: validation

Validate before calling

static boolean isKnownConnectorType(Integer code) {
    return code != null && Arrays.stream(ConnectorType.values()).anyMatch(t -> t.getCode().equals(code));
}

Type guard

static Optional<ConnectorType> safeOf(Integer status) {
    if (status == null) return Optional.empty();
    return Arrays.stream(ConnectorType.values())
            .filter(t -> t.getCode().equals(status))
            .findFirst();
}

Try / catch

try {
    connector = ConnectorType.of(code);
} catch (IllegalArgumentException e) {
    throw new IllegalStateException("Datasource connector type not supported by this build: " + code, e);
}

Prevention

When it happens

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

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

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/b7e1cbb571f1315d. Report an issue: GitHub.