apache/dolphinscheduler · error · IllegalArgumentException
"Cannot find TaskStateAction for state: " + taskExecutionSta
Error message
"Cannot find TaskStateAction for state: " + taskExecutionStatus
What it means
Thrown by TaskStateActionFactory.getTaskStateAction when a TaskExecutionStatus enum value has no registered ITaskStateAction in the internal map. The factory is built by iterating all TaskExecutionStatus values and mapping them to state actions; a null lookup means the mapping table is incomplete or a new enum value was added without an action.
Source
Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskStateActionFactory.java:43
import java.util.Map;
import org.springframework.stereotype.Component;
@Component
public class TaskStateActionFactory {
private final Map<TaskExecutionStatus, ITaskStateAction> taskStateActionMap = new HashMap<>();
public TaskStateActionFactory(List<ITaskStateAction> taskStateActions) {
taskStateActions.forEach(
taskStateAction -> taskStateActionMap.put(taskStateAction.matchState(), taskStateAction));
Arrays.stream(TaskExecutionStatus.values()).forEach(this::getTaskStateAction);
}
public ITaskStateAction getTaskStateAction(final TaskExecutionStatus taskExecutionStatus) {
final ITaskStateAction taskStateAction = taskStateActionMap.get(taskExecutionStatus);
if (taskStateAction == null) {
throw new IllegalArgumentException("Cannot find TaskStateAction for state: " + taskExecutionStatus);
}
return taskStateAction;
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Check TaskExecutionStatus of the failing task and confirm which state has no mapping
- Add/restore the corresponding ITaskStateAction registration in TaskStateActionFactory's constructor
- Upgrade/align master and worker versions so state enums match
- Wrap task state handling to log the raw status before lookup for diagnosis
Example fix
// before
public ITaskStateAction getTaskStateAction(final TaskExecutionStatus status) {
return taskStateActionMap.get(status); // NPE downstream
}
// after
public ITaskStateAction getTaskStateAction(final TaskExecutionStatus status) {
final ITaskStateAction action = taskStateActionMap.get(status);
if (action == null) throw new IllegalArgumentException("Cannot find TaskStateAction for state: " + status);
return action;
} Defensive patterns
Strategy: validation
Validate before calling
if (TaskExecutionStatus.valueOf(status.name()) != null && java.util.Arrays.stream(TaskExecutionStatus.values()).anyMatch(s -> s == status)) {
// proceed; additionally verify factory has an action registered
} Type guard
boolean hasAction(TaskExecutionStatus s) {
return java.util.Arrays.stream(TaskExecutionStatus.values()).anyMatch(v -> v == s);
} Try / catch
try { action = factory.getTaskStateAction(status); } catch (IllegalArgumentException e) { log.error("unmapped state {}", status, e); return; } Prevention
- Register an action for every TaskExecutionStatus value in the factory constructor
- Add a startup self-check that iterates all enum values and looks each up
- Keep master and worker on matching versions
When it happens
Trigger: Calling getTaskStateAction with a TaskExecutionStatus value that was not registered (e.g. KILL, or a newly added enum constant), or an enum value added in a version upgrade whose action implementation is missing.
Common situations: Upgrading DolphinScheduler where a new TaskExecutionStatus was introduced but the state-machine factory wasn't updated; task state callback arriving with an unexpected state from a newer worker.
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
- "The workflow: " + workflowName + " state: " + actualState +
- "The workflow " + workflowExecution.getName() + "is failed,
- "The workflow " + workflowExecution.getName() + "is success,
- The task execution status code: %s is invalidated
- invalid code :
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/3418348fc95acb96.
Report an issue: GitHub.