{"record":{"id":"0c9e16156d9ac33a","repo":"apache/dolphinscheduler","slug":"duplicate-task-name-taskdefinition-getname","errorCode":null,"errorMessage":"\"Duplicate task name: \" + taskDefinition.getName() + \" in the workflow\"","messagePattern":"\"Duplicate task name: \" \\+ taskDefinition\\.getName\\(\\) \\+ \" in the workflow\"","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowGraph.java","lineNumber":52,"sourceCode":"\n    private final Map<Long, TaskDefinition> taskDefinitionCodeMap;\n    private final Map<String, TaskDefinition> taskDefinitionMap;\n\n    private final Map<String, List<String>> predecessors;\n\n    private final Map<String, List<String>> successors;\n\n    public WorkflowGraph(List<WorkflowTaskRelation> workflowTaskRelations, List<TaskDefinition> taskDefinitions) {\n        checkNotNull(taskDefinitions, \"taskDefinitions can not be null\");\n        checkNotNull(workflowTaskRelations, \"taskDefinitions can not be null\");\n        this.predecessors = new HashMap<>();\n        this.successors = new HashMap<>();\n\n        this.taskDefinitionMap = new HashMap<>(taskDefinitions.size());\n        this.taskDefinitionCodeMap = new HashMap<>(taskDefinitions.size());\n        for (TaskDefinition taskDefinition : taskDefinitions) {\n            if (taskDefinitionMap.containsKey(taskDefinition.getName())) {\n                throw new IllegalArgumentException(\n                        \"Duplicate task name: \" + taskDefinition.getName() + \" in the workflow\");\n            }\n            taskDefinitionMap.put(taskDefinition.getName(), taskDefinition);\n            if (taskDefinitionCodeMap.containsKey(taskDefinition.getCode())) {\n                throw new IllegalArgumentException(\n                        \"Duplicate task code: \" + taskDefinition.getCode() + \" in the workflow\");\n            }\n            taskDefinitionCodeMap.put(taskDefinition.getCode(), taskDefinition);\n        }\n\n        addTaskNodes(taskDefinitions);\n        addTaskEdge(workflowTaskRelations);\n    }\n\n    @Override\n    public List<String> getStartNodes() {\n        return predecessors.entrySet()\n                .stream()","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowGraph.java#L34-L70","documentation":"Thrown in the WorkflowGraph constructor when two task definitions in the supplied collection share the same name. The graph indexes tasks by name, so duplicates would make name-based lookups ambiguous; construction fails fast with IllegalArgumentException. A sibling check enforces the same for task codes.","triggerScenarios":"Building a WorkflowGraph from a taskDefinitions list containing two tasks with identical names — typically when the workflow definition from the DB or API payload has duplicate task names.","commonSituations":"Importing a workflow JSON whose tasks were hand-copied with the same name; buggy API clients appending tasks without renaming; corrupted workflow definition data after failed merge/edit.","solutions":["Rename the duplicate task in the workflow definition so every task name is unique, then save and retry.","Audit the workflow import/export payload or DB rows (t_ds_task_definition) for duplicated names.","Fix any client code that constructs workflow definitions to enforce unique task names before submission."],"exampleFix":"// before: duplicate task names in definition list\nnew TaskDefinition(\"copy\", ...); new TaskDefinition(\"copy\", ...);\n// after: unique names\nnew TaskDefinition(\"copy\", ...); new TaskDefinition(\"copy_2\", ...);","handlingStrategy":"validation","validationCode":"// reject duplicate task names before constructing the graph\nSet<String> seen = new HashSet<>();\nfor (TaskDefinition td : taskDefinitions) {\n    if (!seen.add(td.getName()))\n        throw new IllegalStateException(\"Duplicate task name: \" + td.getName());\n}","typeGuard":null,"tryCatchPattern":"try {\n    WorkflowGraph graph = new WorkflowGraph(taskDefinitions, relations);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Duplicate task name:\")) {\n        // deduplicate/rename tasks in the definition set\n    } else throw e;\n}","preventionTips":["Enforce unique task names when authoring or importing workflow JSON.","Validate task definitions for name/code uniqueness before saving workflows.","Review hand-copied task nodes in imported workflows for unchanged names."],"tags":["workflow","dag","duplicate"],"backgroundTag":"invalid-argument-value","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"}