apache/dolphinscheduler · error · IllegalArgumentException

invalid code :

Error message

invalid code : 

What it means

RuleType.of(Integer) throws IllegalArgumentException when the given integer code is not a key in RuleType's VALUES_MAP of known rule-type codes. This is DolphinScheduler's guard against unmapped enum codes arriving from task parameters or persisted definitions. It means the caller passed a rule-type code this build of the library does not recognize.

Source

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

    }

    public String getDescription() {
        return description;
    }

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

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

    public static RuleType 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. Log/print the offending code and compare it against the codes defined in RuleType (the VALUES_MAP keys).
  2. Fix the task definition/parameter so it uses a valid RuleType code from the running version.
  3. If migrating across versions, re-map or re-save the workflow/task so codes are regenerated for the current version.
  4. Guard call sites: check RuleType.contains(status) (or validate the code) before calling of().

Example fix

// before
RuleType type = RuleType.of(params.getRuleType());
// after
Integer code = params.getRuleType();
if (!RuleType.contains(code)) {
    throw new IllegalArgumentException("Unsupported rule type code: " + code);
}
RuleType type = RuleType.of(code);
Defensive patterns

Strategy: validation

Validate before calling

if (code == null || !RuleType.contains(code)) {
    throw new IllegalArgumentException("Unknown RuleType code: " + code);
}

Type guard

boolean isValidRuleType(Integer code) {
    return code != null && RuleType.contains(code);
}

Try / catch

try {
    RuleType type = RuleType.of(code);
} catch (IllegalArgumentException e) {
    log.error("Unrecognized rule type code, falling back to default", e);
    RuleType type = RuleType.getDefault(); // or fail fast with a clear message
}

Prevention

When it happens

Trigger: Calling RuleType.of(status) with null, or with an integer that is not one of the enum's defined codes (e.g. a code stored by a newer/older DolphinScheduler version, or a hand-edited task definition).

Common situations: Upgrading/downgrading DolphinScheduler so persisted rule-type codes no longer exist; copying a task definition JSON between environments; manually editing task params and typing a wrong rule type number; passing an uninitialized Integer field.

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