{"record":{"id":"af71960246aaaf80","repo":"apache/dolphinscheduler","slug":"cannot-find-the-task-code-in-graph","errorCode":null,"errorMessage":"\"Cannot find the task code in graph\"","messagePattern":"\"Cannot find the task code in graph\"","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowExecutionGraph.java","lineNumber":128,"sourceCode":"                .collect(Collectors.toList());\n    }\n\n    @Override\n    public List<ITaskExecution> getPredecessors(final String taskName) {\n        if (!predecessors.containsKey(taskName)) {\n            throw new IllegalArgumentException(\"Cannot find the task: \" + taskName + \" in graph\");\n        }\n        return predecessors\n                .get(taskName)\n                .stream()\n                .map(this::getTaskExecutionByName)\n                .collect(Collectors.toList());\n    }\n\n    @Override\n    public List<ITaskExecution> getSuccessors(final String taskName) {\n        if (!successors.containsKey(taskName)) {\n            throw new IllegalArgumentException(\"Cannot find the task code in graph\");\n        }\n        return successors\n                .get(taskName)\n                .stream()\n                .map(this::getTaskExecutionByName)\n                .collect(Collectors.toList());\n    }\n\n    @Override\n    public List<ITaskExecution> getSuccessors(final ITaskExecution taskExecution) {\n        return getSuccessors(taskExecution.getName());\n    }\n\n    @Override\n    public ITaskExecution getTaskExecutionByName(final String taskName) {\n        return totalTaskExecuteRunnableMap.get(taskName);\n    }\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowExecutionGraph.java#L110-L146","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the task name is part of the current workflow before traversing its successors.","Rebuild or re-fetch the WorkflowExecutionGraph from the latest workflow instance data.","Update any hardcoded/traversed task names to match the current DAG after edits."],"exampleFix":"// before\ngraph.getSuccessors(\"removed_task\").forEach(...);\n// after\nif (graph.getAllTaskExecutions().stream().anyMatch(t -> t.getName().equals(\"removed_task\"))) {\n    graph.getSuccessors(\"removed_task\").forEach(...);\n}","handlingStrategy":"type-guard","validationCode":"// confirm the task exists before traversing successors\nboolean exists = graph.getAllTaskExecutions().stream()\n    .anyMatch(t -> t.getName().equals(taskName));\nif (!exists) return Collections.emptyList();","typeGuard":"boolean taskInGraph(WorkflowExecutionGraph graph, String name) {\n    return graph.getAllTaskExecutions().stream().anyMatch(t -> t.getName().equals(name));\n}","tryCatchPattern":"try {\n    List<ITaskExecution> succs = graph.getSuccessors(taskName);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Cannot find the task code in graph\")) {\n        succs = Collections.emptyList();\n    } else throw e;\n}","preventionTips":["Traverse only task names present in the current WorkflowExecutionGraph.","Refresh graph references after task deletion or workflow edits.","Guard chained traversals where intermediate tasks may be absent."],"tags":["workflow","dag","lookup"],"backgroundTag":"record-not-found","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}