apache/dolphinscheduler · error · IllegalArgumentException

The task execution status code: %s is invalidated

Error message

The task execution status code: %s is invalidated

What it means

TaskExecutionStatus.of(code) throws IllegalArgumentException when the given integer is not a known task execution status code (registered in CODE_MAP). DolphinScheduler uses this enum to translate DB/API status codes into the enum; an unknown code means corrupted data, a version mismatch, or a programming bug rather than a runtime condition.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/TaskExecutionStatus.java:55

    DISPATCH(17, "dispatch"),

    ;

    private static final Map<Integer, TaskExecutionStatus> CODE_MAP = new HashMap<>();

    static {
        for (TaskExecutionStatus executionStatus : TaskExecutionStatus.values()) {
            CODE_MAP.put(executionStatus.getCode(), executionStatus);
        }
    }

    /**
     * Get <code>TaskExecutionStatus</code> by code, if the code is invalidated will throw {@link IllegalArgumentException}.
     */
    public static TaskExecutionStatus of(int code) {
        TaskExecutionStatus taskExecutionStatus = CODE_MAP.get(code);
        if (taskExecutionStatus == null) {
            throw new IllegalArgumentException(String.format("The task execution status code: %s is invalidated",
                    code));
        }
        return taskExecutionStatus;
    }

    public boolean isRunning() {
        return this == RUNNING_EXECUTION;
    }

    public boolean isSuccess() {
        return this == TaskExecutionStatus.SUCCESS;
    }

    public boolean isForceSuccess() {
        return this == TaskExecutionStatus.FORCED_SUCCESS;
    }

    public boolean isKill() {

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the code being passed against the valid constants in TaskExecutionStatus (SUBMITTED_SUCCESS=0, RUNNING_EXECUTION=1, ... ) and fix the producer of the invalid code.
  2. Use the enum constants instead of raw integers when converting (TaskExecutionStatus.RUNNING_EXECUTION rather than of(1)).
  3. If data comes from the database, fix the corrupted state row or migrate it to a valid code per your DolphinScheduler version.
  4. Guard with a map lookup or catch IllegalArgumentException when codes may come from external input.

Example fix

// before
TaskExecutionStatus status = TaskExecutionStatus.of(rawValue);

// after: validate before converting
TaskExecutionStatus status = Arrays.stream(TaskExecutionStatus.values())
        .filter(s -> s.getCode() == rawValue)
        .findFirst()
        .orElseThrow(() -> new IllegalStateException("Unknown task status code: " + rawValue));
Defensive patterns

Strategy: validation

Validate before calling

static boolean isValidStatusCode(int code) {
    return Arrays.stream(TaskExecutionStatus.values()).anyMatch(s -> s.getCode() == code);
}
// usage: if (!isValidStatusCode(code)) { log.warn("bad status code {}", code); return; }

Type guard

static Optional<TaskExecutionStatus> safeOf(int code) {
    return Arrays.stream(TaskExecutionStatus.values())
            .filter(s -> s.getCode() == code)
            .findFirst();
}

Try / catch

try {
    status = TaskExecutionStatus.of(code);
} catch (IllegalArgumentException e) {
    log.warn("Unknown task execution status code: {}, defaulting to FAILURE", code);
    status = TaskExecutionStatus.FAILURE;
}

Prevention

When it happens

Trigger: Calling TaskExecutionStatus.of(int) with a code not produced by the enum (e.g. 99, -1, or a code from a newer/older DolphinScheduler version); deserializing a task instance from the database whose state column contains an out-of-range value; passing a ProcessExecutionStatus code into the task-status enum by mistake.

Common situations: Upgrading/downgrading DolphinScheduler so stored status codes no longer match the enum; hand-written SQL or ETL jobs writing invalid state values into t_ds_task_instance; API clients submitting an invalid state code; confusing task vs process execution status code spaces.

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