apache/dolphinscheduler · error · ServiceException
10168
10168
Error message
workflow definition name {0} already exists What it means
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.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:258
String taskRelationJson,
String taskDefinitionJson,
String otherParamsJson,
WorkflowExecutionTypeEnum executionType) {
Project project = projectDao.queryByCode(projectCode);
// check if user have write perm for project
projectService.checkHasProjectWritePermissionThrowException(loginUser, project);
if (checkDescriptionLength(description)) {
log.warn("Parameter description is too long.");
throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR);
}
// check whether the new workflow definition name exist
WorkflowDefinition definition = workflowDefinitionDao.verifyByDefineName(project.getCode(), name);
if (definition != null) {
log.warn("workflow definition with the same name {} already exists, workflowDefinitionCode:{}.",
definition.getName(), definition.getCode());
throw new ServiceException(Status.WORKFLOW_DEFINITION_NAME_EXIST, name);
}
globalParamsValidator.validate(globalParams);
List<TaskDefinitionLog> taskDefinitionLogs = generateTaskDefinitionList(taskDefinitionJson);
List<WorkflowTaskRelationLog> taskRelationList = generateTaskRelationList(taskRelationJson, taskDefinitionLogs);
long workflowDefinitionCode = CodeGenerateUtils.genCode();
WorkflowDefinition workflowDefinition =
new WorkflowDefinition(projectCode, name, workflowDefinitionCode, description,
globalParams, locations, timeout, loginUser.getId());
workflowDefinition.setExecutionType(executionType);
return createDagDefine(loginUser, taskRelationList, workflowDefinition, taskDefinitionLogs);
}
protected WorkflowDefinition createDagDefine(User loginUser,
List<WorkflowTaskRelationLog> taskRelationList,View on GitHub (pinned to 02eac45a1b)
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.
Example fix
// before createWorkflowDefinition(project, "daily_etl", ...) // exists -> 10168 // after WorkflowDefinition existing = dao.verifyByDefineName(projectCode, "daily_etl"); if (existing == null) createWorkflowDefinition(...); else updateWorkflowDefinition(existing, ...);
Defensive patterns
Strategy: validation
Validate before calling
WorkflowDefinition existing = workflowDefinitionDao.verifyByDefineName(projectCode, name); boolean canCreate = existing == null;
Try / catch
try {
workflowDefinitionService.createWorkflowDefinition(...);
} catch (ServiceException e) {
if (e.getCode() == 10168) { /* fall back to update by code */ }
else throw e;
} Prevention
- Make provisioning scripts idempotent: query by name first, update if present.
- Use unique, timestamped names for generated workflows.
- Guard UI forms against double submit.
When it happens
Trigger: POST creating a workflow whose (projectCode, name) pair already exists; re-running an import script; UI duplicate submit.
Common situations: Importing a workflow JSON twice; renaming projects then recreating same-named workflows; concurrent creation by two users; CI/CD workflow provisioning without idempotency.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/5c44fcad857fc1b5.
Report an issue: GitHub.