apache/dolphinscheduler · error · IllegalArgumentException

invalid code :

Error message

invalid code : 

What it means

OperatorType.of(Integer) throws IllegalArgumentException when the given code is not present in VALUES_MAP. OperatorType enumerates comparison operators used in data-quality check rules (e.g. equals, greater-than); an unmapped code means a rule references an operator this build does not define.

Source

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

    }

    public String getDescription() {
        return description;
    }

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

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

    public static OperatorType 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. Check the operator code in the data-quality rule parameters against OperatorType constants and correct it.
  2. Use OperatorType enum constants instead of raw integers when building rules.
  3. Remap persisted rule codes after upgrading DolphinScheduler.
  4. Catch IllegalArgumentException when loading external rules and skip/report the invalid rule.

Example fix

// before
OperatorType op = OperatorType.of(rule.getOperator());

// after: defensive parsing
OperatorType op = Arrays.stream(OperatorType.values())
        .filter(o -> o.getCode().equals(rule.getOperator()))
        .findFirst()
        .orElseThrow(() -> new IllegalArgumentException("Unknown operator code in rule " + rule.getName()));
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

try {
    op = OperatorType.of(code);
} catch (IllegalArgumentException e) {
    log.error("Rule references unknown operator {}", code);
    throw new IllegalStateException("Data-quality rule has invalid operator code: " + code, e);
}

Prevention

When it happens

Trigger: Calling OperatorType.of() with an Integer absent from VALUES_MAP — typically when a data-quality rule's operator field in task parameters holds an unknown value, codes were copied from another enum, or stored rules predate an enum change.

Common situations: Authoring data-quality comparison rules by hand; exporting/importing workflows between DolphinScheduler versions with different operator codes; frontend/API writing operator indices that no longer match backend enum order.

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