apache/dolphinscheduler · error · IllegalArgumentException

invalid code :

Error message

invalid code : 

What it means

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.

Source

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

    }

    public String getDescription() {
        return description;
    }

    private static final Map<Integer, DataType> DATA_TYPE_MAP = new HashMap<>();

    static {
        for (DataType type : DataType.values()) {
            DATA_TYPE_MAP.put(type.code, type);
        }
    }

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

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the dataType code in the data-quality task parameters against the DataType constants and fix it.
  2. Use DataType enum constants when generating parameters instead of raw ints.
  3. If definitions were exported from another DolphinScheduler version, re-map stored codes to the current DataType codes.
  4. Validate the code is present in DataType's map before calling of().

Example fix

// before
DataType dataType = DataType.of(code);

// after: safe parse
DataType dataType = code == null ? DataType.VARCHAR : DataType.of(code);
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

try {
    dataType = DataType.of(code);
} catch (IllegalArgumentException e) {
    log.warn("Unknown data type code {}, defaulting to VARCHAR", code);
    dataType = DataType.VARCHAR;
}

Prevention

When it happens

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

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

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