apache/dolphinscheduler · error · IllegalArgumentException

"Cannot find the task code in graph"

Error message

"Cannot find the task code in graph"

What it means

Thrown by WorkflowExecutionGraph.getSuccessors(String) when the taskName is absent from the successors map, meaning the task is not part of the executing graph. The message is generic ('Cannot find the task code in graph') even though the lookup key is a task name. Like getPredecessors, it is an IllegalArgumentException signaling an invalid lookup against the built graph.

Source

Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowExecutionGraph.java:128

                .collect(Collectors.toList());
    }

    @Override
    public List<ITaskExecution> getPredecessors(final String taskName) {
        if (!predecessors.containsKey(taskName)) {
            throw new IllegalArgumentException("Cannot find the task: " + taskName + " in graph");
        }
        return predecessors
                .get(taskName)
                .stream()
                .map(this::getTaskExecutionByName)
                .collect(Collectors.toList());
    }

    @Override
    public List<ITaskExecution> getSuccessors(final String taskName) {
        if (!successors.containsKey(taskName)) {
            throw new IllegalArgumentException("Cannot find the task code in graph");
        }
        return successors
                .get(taskName)
                .stream()
                .map(this::getTaskExecutionByName)
                .collect(Collectors.toList());
    }

    @Override
    public List<ITaskExecution> getSuccessors(final ITaskExecution taskExecution) {
        return getSuccessors(taskExecution.getName());
    }

    @Override
    public ITaskExecution getTaskExecutionByName(final String taskName) {
        return totalTaskExecuteRunnableMap.get(taskName);
    }

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Confirm the task name is part of the current workflow before traversing its successors.
  2. Rebuild or re-fetch the WorkflowExecutionGraph from the latest workflow instance data.
  3. Update any hardcoded/traversed task names to match the current DAG after edits.

Example fix

// before
graph.getSuccessors("removed_task").forEach(...);
// after
if (graph.getAllTaskExecutions().stream().anyMatch(t -> t.getName().equals("removed_task"))) {
    graph.getSuccessors("removed_task").forEach(...);
}
Defensive patterns

Strategy: type-guard

Validate before calling

// confirm the task exists before traversing successors
boolean exists = graph.getAllTaskExecutions().stream()
    .anyMatch(t -> t.getName().equals(taskName));
if (!exists) return Collections.emptyList();

Type guard

boolean taskInGraph(WorkflowExecutionGraph graph, String name) {
    return graph.getAllTaskExecutions().stream().anyMatch(t -> t.getName().equals(name));
}

Try / catch

try {
    List<ITaskExecution> succs = graph.getSuccessors(taskName);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("Cannot find the task code in graph")) {
        succs = Collections.emptyList();
    } else throw e;
}

Prevention

When it happens

Trigger: Calling getSuccessors with a task name not registered in the graph — e.g. successors() traversal over a name from a stale workflow version, or chained getSuccessors(getSuccessors(...)) where an intermediate task has no entry.

Common situations: Graph traversal code iterating names from an outdated definition snapshot; tasks deleted while a workflow instance is running; plugins walking the DAG by hardcoded names.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/af71960246aaaf80. Report an issue: GitHub.