apache/dolphinscheduler · error · IllegalArgumentException

The task execution status code: %s is invalid

Error message

The task execution status code: %s is invalid

What it means

ListenerEventType.of(int) is the code-to-enum converter for workflow/task listener event types. It throws IllegalArgumentException when the given integer is not a registered event type code in CODE_MAP, meaning the payload came from an unknown or incompatible version of DolphinScheduler event types.

Source

Thrown at dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/ListenerEventType.java:61

    static {
        for (ListenerEventType listenerEventType : ListenerEventType.values()) {
            CODE_MAP.put(listenerEventType.getCode(), listenerEventType);
        }
    }

    @EnumValue
    private final int code;
    private final String descp;

    ListenerEventType(int code, String descp) {
        this.code = code;
        this.descp = descp;
    }

    public static ListenerEventType of(int code) {
        ListenerEventType listenerEventType = CODE_MAP.get(code);
        if (listenerEventType == null) {
            throw new IllegalArgumentException(String.format("The task execution status code: %s is invalid",
                    code));
        }
        return listenerEventType;
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Print the offending code and map it to ListenerEventType's defined codes; use the correct code constant from the enum instead of a magic number.
  2. Check version alignment between the event producer and consumer — upgrade or downgrade so both use the same ListenerEventType code set.
  3. Before calling of(), guard with an unknown-code fallback: CODE_MAP keys check or a try/catch that logs and skips unknown events.

Example fix

// before
ListenerEventType type = ListenerEventType.of(rawCode);

// after
ListenerEventType type = Arrays.stream(ListenerEventType.values())
        .filter(t -> t.getCode() == rawCode)
        .findFirst()
        .orElseThrow(() -> new IllegalArgumentException(
            "Unsupported listener event code: " + rawCode + ", known codes: " +
            Arrays.toString(ListenerEventType.values())));
Defensive patterns

Strategy: try-catch

Validate before calling

boolean isValidEventType(int code) {
    return Arrays.stream(ListenerEventType.values()).anyMatch(t -> t.getCode() == code);
}

Try / catch

try {
    ListenerEventType type = ListenerEventType.of(code);
    handle(type);
} catch (IllegalArgumentException e) {
    log.warn("Unknown listener event code {} — skipping (possible version mismatch)", code, e);
}

Prevention

When it happens

Trigger: Calling ListenerEventType.of(code) with an int that is not one of the enum's defined codes — e.g. deserializing a listener event from a cluster running a newer/older version whose codes differ, or passing a task execution status code by mistake (the message mentions status codes but the enum is event types).

Common situations: Event/plugin consumer deserializes MQ/log events across mixed-version clusters; custom plugin passes wrong integer field; enum codes changed after an upgrade so persisted/forwarded codes no longer resolve.

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