apache/dolphinscheduler · error · IllegalArgumentException
"Cannot find the task: " + taskName + " in graph"
Error message
"Cannot find the task: " + taskName + " in graph"
What it means
Thrown by WorkflowExecutionGraph.getPredecessors when the requested taskName is not a key in the graph's predecessors map, i.e. the task does not exist in the executing workflow graph. Callers such as isTriggerConditionMet and predecessors rely on every referenced task being registered when the graph was built. This is an internal lookup failure indicating a caller passed a name the graph never contains.
Source
Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowExecutionGraph.java:116
}
};
removeUnReachableEdge.accept(successors);
removeUnReachableEdge.accept(predecessors);
}
@Override
public List<ITaskExecution> getStartNodes() {
return totalTaskExecuteRunnableMap.values()
.stream()
.filter(taskExecution -> CollectionUtils
.isEmpty(predecessors.get(taskExecution.getName())))
.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());View on GitHub (pinned to 02eac45a1b)
Solutions
- Verify the task name exists in the workflow graph before calling getPredecessors (check getTaskExecutionByName or the task list).
- Re-fetch/rebuild the workflow execution graph so it reflects the current task definitions.
- Fix plugin/task params that reference tasks by old names after renames.
Example fix
// before: unchecked lookup
List<ITaskExecution> preds = graph.getPredecessors("old_task_name");
// after: guard first
if (graph.getTaskExecutionMap().containsKey("old_task_name")) {
List<ITaskExecution> preds = graph.getPredecessors("old_task_name");
} Defensive patterns
Strategy: type-guard
Validate before calling
// confirm the task exists in the graph before lookup
boolean exists = graph.getAllTaskExecutions().stream()
.anyMatch(t -> t.getName().equals(taskName));
if (!exists) return Collections.emptyList(); // or log and skip Type guard
boolean taskInGraph(WorkflowExecutionGraph graph, String name) {
return graph.getAllTaskExecutions().stream().anyMatch(t -> t.getName().equals(name));
} Try / catch
try {
List<ITaskExecution> preds = graph.getPredecessors(taskName);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Cannot find the task:")) {
preds = Collections.emptyList(); // task absent from this graph version
} else throw e;
} Prevention
- Derive task names for graph queries from the graph itself, not stale snapshots.
- Avoid hardcoding task names in plugins that walk the DAG.
- Re-resolve names after any workflow rename or restructure.
When it happens
Trigger: Querying predecessors of a task name absent from the workflow — e.g. isTriggerConditionMet on a task not added during graph construction, or plugin code asking for a task referenced only in params but not present as a DAG node.
Common situations: Task renamed between workflow build and lookup; logic-task plugin referencing a dependency by stale name; concurrent workflow modification; calling master-internal graph APIs with names from a different workflow version.
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
- "Cannot find the task code in graph"
- The branch(code= ${branchNode}) is not in the dag, please ch
- "Duplicate task name: " + taskDefinition.getName() + " in th
- Recover workflow instance failed: %s
- The workflow instance: %s status is %s, cannot repeat runnin
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/64d148bb736f6713.
Report an issue: GitHub.