{"record":{"id":"3ac100bfa933fda7","repo":"apache/dolphinscheduler","slug":"task-group-name-exsit","errorCode":"TASK_GROUP_NAME_EXSIT","errorMessage":"Task group with the same name already exists, taskGroupName:{}.","messagePattern":"Task group with the same name already exists, taskGroupName:(.+?)\\.","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java","lineNumber":94,"sourceCode":"    @Override\n    @Transactional\n    public TaskGroup createTaskGroup(User loginUser, Long projectCode, String name, String description, int groupSize) {\n        requireProjectPerm(loginUser, projectCode, true);\n        if (checkDescriptionLength(description)) {\n            log.warn(\"Parameter description is too long.\");\n            throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR);\n        }\n        if (name == null) {\n            log.warn(\"Parameter name can ot be null.\");\n            throw new ServiceException(Status.NAME_NULL);\n        }\n        if (groupSize <= 0) {\n            log.warn(\"Parameter task group size is must bigger than 1.\");\n            throw new ServiceException(Status.TASK_GROUP_SIZE_ERROR);\n        }\n        TaskGroup duplicate = taskGroupMapper.queryByName(loginUser.getId(), name);\n        if (duplicate != null) {\n            log.warn(\"Task group with the same name already exists, taskGroupName:{}.\", duplicate.getName());\n            throw new ServiceException(Status.TASK_GROUP_NAME_EXSIT);\n        }\n        Date now = new Date();\n        TaskGroup taskGroup = TaskGroup.builder()\n                .name(name)\n                .projectCode(projectCode)\n                .description(description)\n                .groupSize(groupSize)\n                .userId(loginUser.getId())\n                .status(Flag.YES)\n                .createTime(now)\n                .updateTime(now)\n                .build();\n\n        if (taskGroupMapper.insert(taskGroup) <= 0) {\n            log.error(\"Create task group error, taskGroupName:{}.\", taskGroup.getName());\n            throw new ServiceException(Status.CREATE_TASK_GROUP_ERROR);\n        }","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java#L76-L112","documentation":"createTaskGroup enforces per-user name uniqueness: it queries taskGroupMapper.queryByName(loginUser.getId(), name) and, if a duplicate is found, throws ServiceException(Status.TASK_GROUP_NAME_EXSIT). Task group names must be unique within a user's scope, so creation is refused and the transaction rolls back.","triggerScenarios":"Creating a task group whose name already exists for the same user; re-running an idempotency-assuming provisioning script; two tabs submitting the same form twice.","commonSituations":"Retry after a timeout that actually succeeded; migration scripts re-importing groups; teams sharing a service account hitting the same names; misspelled 'rename then create' flows.","solutions":["Query existing task groups first and reuse or rename before creating.","Catch TASK_GROUP_NAME_EXSIT and surface a 'name already in use' message prompting a new name.","Adopt a naming convention with suffixes (project/env/date) to avoid collisions.","If the old group is stale, delete or rename it, then create the new one."],"exampleFix":"// before\nawait createTaskGroup({ name: 'etl-group', groupSize: 10 }) // fails on retry\n// after\nconst existing = await queryTaskGroupList({ searchVal: 'etl-group' })\nif (!existing.totalList.some(g => g.name === 'etl-group')) {\n  await createTaskGroup({ name: 'etl-group', groupSize: 10 })\n}","handlingStrategy":"try-catch","validationCode":"const existing = await queryTaskGroupList({ searchVal: name })\nconst isDuplicate = existing.totalList?.some(g => g.name === name)\nif (isDuplicate) throw new Error(`Task group '${name}' already exists`)","typeGuard":null,"tryCatchPattern":"try {\n  await createTaskGroup(payload)\n} catch (e) {\n  if (isServiceException(e, 'TASK_GROUP_NAME_EXSIT')) {\n    const alt = `${payload.name}-${Date.now()}`\n    await createTaskGroup({ ...payload, name: alt })\n  } else throw e\n}","preventionTips":["Check for an existing group with the same name before creating (search-then-create).","Use namespaced naming conventions (user/project/env) to reduce collisions.","Make retry scripts idempotent: look up before create instead of blind re-post.","Surface the server error as a friendly 'name already in use' prompt."],"tags":["duplicate","uniqueness","api"],"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-14T05:17:10.506Z"}