{"record":{"id":"5c44fcad857fc1b5","repo":"apache/dolphinscheduler","slug":"10168","errorCode":"10168","errorMessage":"workflow definition name {0} already exists","messagePattern":"workflow definition name (.+?) already exists","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":258,"sourceCode":"                                                       String taskRelationJson,\n                                                       String taskDefinitionJson,\n                                                       String otherParamsJson,\n                                                       WorkflowExecutionTypeEnum executionType) {\n        Project project = projectDao.queryByCode(projectCode);\n\n        // check if user have write perm for project\n        projectService.checkHasProjectWritePermissionThrowException(loginUser, project);\n\n        if (checkDescriptionLength(description)) {\n            log.warn(\"Parameter description is too long.\");\n            throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR);\n        }\n        // check whether the new workflow definition name exist\n        WorkflowDefinition definition = workflowDefinitionDao.verifyByDefineName(project.getCode(), name);\n        if (definition != null) {\n            log.warn(\"workflow definition with the same name {} already exists, workflowDefinitionCode:{}.\",\n                    definition.getName(), definition.getCode());\n            throw new ServiceException(Status.WORKFLOW_DEFINITION_NAME_EXIST, name);\n        }\n\n        globalParamsValidator.validate(globalParams);\n\n        List<TaskDefinitionLog> taskDefinitionLogs = generateTaskDefinitionList(taskDefinitionJson);\n        List<WorkflowTaskRelationLog> taskRelationList = generateTaskRelationList(taskRelationJson, taskDefinitionLogs);\n\n        long workflowDefinitionCode = CodeGenerateUtils.genCode();\n        WorkflowDefinition workflowDefinition =\n                new WorkflowDefinition(projectCode, name, workflowDefinitionCode, description,\n                        globalParams, locations, timeout, loginUser.getId());\n        workflowDefinition.setExecutionType(executionType);\n\n        return createDagDefine(loginUser, taskRelationList, workflowDefinition, taskDefinitionLogs);\n    }\n\n    protected WorkflowDefinition createDagDefine(User loginUser,\n                                                 List<WorkflowTaskRelationLog> taskRelationList,","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L240-L276","documentation":"Thrown by createWorkflowDefinition when workflowDefinitionDao.verifyByDefineName(project.getCode(), name) returns an existing definition, meaning a workflow with the same name already exists in that project. Names are unique per project.","triggerScenarios":"POST creating a workflow whose (projectCode, name) pair already exists; re-running an import script; UI duplicate submit.","commonSituations":"Importing a workflow JSON twice; renaming projects then recreating same-named workflows; concurrent creation by two users; CI/CD workflow provisioning without idempotency.","solutions":["Choose a unique workflow name within the project, or delete/rename the existing workflow.","Make import scripts idempotent: look up the existing definition by name first and update instead of create.","Use the updateWorkflowDefinition API (with code+version) when the workflow already exists."],"exampleFix":"// before\ncreateWorkflowDefinition(project, \"daily_etl\", ...) // exists -> 10168\n// after\nWorkflowDefinition existing = dao.verifyByDefineName(projectCode, \"daily_etl\");\nif (existing == null) createWorkflowDefinition(...); else updateWorkflowDefinition(existing, ...);","handlingStrategy":"validation","validationCode":"WorkflowDefinition existing = workflowDefinitionDao.verifyByDefineName(projectCode, name);\nboolean canCreate = existing == null;","typeGuard":null,"tryCatchPattern":"try {\n    workflowDefinitionService.createWorkflowDefinition(...);\n} catch (ServiceException e) {\n    if (e.getCode() == 10168) { /* fall back to update by code */ }\n    else throw e;\n}","preventionTips":["Make provisioning scripts idempotent: query by name first, update if present.","Use unique, timestamped names for generated workflows.","Guard UI forms against double submit."],"tags":["workflow-definition","duplicate-name","create"],"backgroundTag":"file-already-exists","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"}