{"record":{"id":"bc8b0b0ebd6873df","repo":"apache/dolphinscheduler","slug":"10198","errorCode":"10198","errorMessage":"task name {0} duplicate error","messagePattern":"task name (.+?) duplicate error","errorType":"validation","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":372,"sourceCode":"    }\n\n    private List<TaskDefinitionLog> generateTaskDefinitionList(String taskDefinitionJson) {\n        try {\n            List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class);\n\n            if (CollectionUtils.isEmpty(taskDefinitionLogs)) {\n                log.error(\"Generate task definition list failed, the given taskDefinitionJson is invalided: {}\",\n                        taskDefinitionJson);\n                throw new ServiceException(Status.DATA_IS_NOT_VALID, taskDefinitionJson);\n            }\n\n            Set<String> taskNameSet = new HashSet<>();\n            for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) {\n                if (!taskNameSet.add(taskDefinitionLog.getName())) {\n                    log.error(\n                            \"Generate task definition list failed, the given task definition name is duplicate, taskName: {}, taskDefinition: {}\",\n                            taskDefinitionLog.getName(), taskDefinitionLog);\n                    throw new ServiceException(Status.TASK_NAME_DUPLICATE_ERROR, taskDefinitionLog.getName());\n                }\n\n                if (!checkTaskParameters(taskDefinitionLog.getTaskType(), taskDefinitionLog.getTaskParams())) {\n                    log.error(\n                            \"Generate task definition list failed, the given task definition parameter is invalided, taskName: {}, taskDefinition: {}\",\n                            taskDefinitionLog.getName(), taskDefinitionLog);\n                    throw new ServiceException(Status.WORKFLOW_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName());\n                }\n            }\n            return taskDefinitionLogs;\n        } catch (ServiceException ex) {\n            throw ex;\n        } catch (Exception e) {\n            log.error(\"Generate task definition list failed, meet an unknown exception\", e);\n            throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR);\n        }\n    }\n","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L354-L390","documentation":"Thrown when two or more task definitions in the submitted taskDefinitionJson share the same task name. Task names must be unique within a workflow definition, enforced via a HashSet during generation of the task definition list.","triggerScenarios":"Calling importWorkflowDefinition or updateWorkflowDefinition where two entries in taskDefinitionJson have identical name fields.","commonSituations":"Copy-pasting a task block in the workflow JSON and forgetting to rename it; script-generated JSON with a loop that reuses the name; merging workflows that had same-named tasks.","solutions":["Rename the duplicated task in taskDefinitionJson so every name is unique","Re-generate the JSON from the workflow designer UI instead of editing raw JSON","Search the JSON programmatically for duplicate name values before submitting"],"exampleFix":"// before\n[{\"name\":\"task1\",...},{\"name\":\"task1\",...}]\n// after\n[{\"name\":\"task1\",...},{\"name\":\"task2\",...}]","handlingStrategy":"validation","validationCode":"Set<String> names = new HashSet<>(); for (TaskDefinitionLog d : defs) if (!names.add(d.getName())) throw new IllegalArgumentException(\"duplicate task name: \" + d.getName());","typeGuard":"static boolean uniqueNames(List<TaskDefinitionLog> defs) { return defs.stream().map(TaskDefinitionLog::getName).distinct().count() == defs.size(); }","tryCatchPattern":"try { ... } catch (ServiceException e) { if (e.getCode() == 10198) { log.error(\"duplicate task name: {}\", e.getMessage()); } }","preventionTips":["Rename after copy-pasting task blocks","Enforce unique naming in any JSON generator script","Use the UI designer which blocks duplicate names client-side"],"tags":["api","validation","duplicate","dolphinscheduler"],"backgroundTag":"duplicate-identifier","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"}