{"record":{"id":"9e59920813597f32","repo":"apache/dolphinscheduler","slug":"cannot-find-task-taskname","errorCode":null,"errorMessage":"\"Cannot find task: \" + taskName","messagePattern":"\"Cannot find task: \" \\+ taskName","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowGraph.java","lineNumber":90,"sourceCode":"                .map(Map.Entry::getKey)\n                .collect(Collectors.toList());\n    }\n\n    @Override\n    public Set<String> getPredecessors(String taskName) {\n        return new HashSet<>(predecessors.get(taskName));\n    }\n\n    @Override\n    public Set<String> getSuccessors(String taskName) {\n        return new HashSet<>(successors.get(taskName));\n    }\n\n    @Override\n    public TaskDefinition getTaskNodeByName(String taskName) {\n        TaskDefinition taskDefinition = taskDefinitionMap.get(taskName);\n        if (taskDefinition == null) {\n            throw new IllegalArgumentException(\"Cannot find task: \" + taskName);\n        }\n        return taskDefinition;\n    }\n\n    @Override\n    public TaskDefinition getTaskNodeByCode(Long taskCode) {\n        TaskDefinition taskDefinition = taskDefinitionCodeMap.get(taskCode);\n        if (taskDefinition == null) {\n            throw new IllegalArgumentException(\"Cannot find task: \" + taskCode);\n        }\n        return taskDefinition;\n    }\n\n    @Override\n    public List<TaskDefinition> getAllTaskNodes() {\n        return new ArrayList<>(taskDefinitionMap.values());\n    }\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowGraph.java#L72-L108","documentation":"getTaskNodeByName looks up a TaskDefinition by its name in the workflow graph's name-indexed map. If no task with that name exists in the graph, it throws this IllegalArgumentException. The graph only contains tasks that were part of the workflow definition it was built from.","triggerScenarios":"Calling workflowGraph.getTaskNodeByName(name) with a task name that is not among the workflow's task definitions — e.g. a name typed incorrectly, a task removed from the workflow, or a name belonging to another workflow.","commonSituations":"Logic/workflow code referencing a task that was renamed or deleted; case-mismatched task names; querying a partially-started workflow where only some tasks were added to the graph; stale failover/recovery logic referencing old task names.","solutions":["Verify the exact task name exists in the workflow definition (getAllTaskNodes()) before calling getTaskNodeByName","Use getTaskNodeByCode(Long) with the stable task code instead of the mutable name","If the task was renamed, update the caller's configuration/code with the new name","Catch IllegalArgumentException and handle the missing-task case explicitly where absence is expected"],"exampleFix":"// before\nTaskDefinition td = workflowGraph.getTaskNodeByName(\"PRCESS_DATA\"); // typo\n// after\nString name = \"PROCESS_DATA\";\nboolean exists = workflowGraph.getAllTaskNodes().stream().anyMatch(t -> t.getName().equals(name));\nif (!exists) throw new IllegalStateException(\"Workflow has no task named \" + name);\nTaskDefinition td = workflowGraph.getTaskNodeByName(name);","handlingStrategy":"validation","validationCode":"boolean exists = workflowGraph.getAllTaskNodes().stream()\n        .anyMatch(t -> t.getName().equals(taskName));\nif (!exists) throw new IllegalStateException(\"No task named \" + taskName + \" in this workflow\");","typeGuard":"Optional<TaskDefinition> findByName(WorkflowGraph g, String name) {\n    return g.getAllTaskNodes().stream().filter(t -> t.getName().equals(name)).findFirst();\n}","tryCatchPattern":"try {\n    TaskDefinition td = workflowGraph.getTaskNodeByName(taskName);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Task {} not found in workflow graph\", taskName, e);\n    return null; // or skip this dependent\n}","preventionTips":["Reference tasks by code (stable) rather than name (mutable)","Check the workflow definition after renames/deletions and update all referencing logic","Match names exactly — no case-insensitive or trimmed assumptions","Validate task names in workflow JSON/DAG editors before saving"],"tags":["workflow-graph","task-lookup","not-found"],"backgroundTag":"resource-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"}