{"record":{"id":"f4a0bc280e46ebaa","repo":"apache/dolphinscheduler","slug":"130001","errorCode":"130001","errorMessage":"this task group name is repeated in a project","messagePattern":"this task group name is repeated in a project","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java","lineNumber":95,"sourceCode":"    @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        }\n        log.info(\"Create task group complete, taskGroupName:{}.\", taskGroup.getName());","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java#L77-L113","documentation":"createTaskGroup checks taskGroupMapper.queryByName(loginUser.getId(), name) and throws Status.TASK_GROUP_NAME_EXSIT (code 130001) if a group with the same name already exists for this user. Names are unique per user, so duplicate creation is rejected.","triggerScenarios":"POST /task-group/update-or-create (create path) where the authenticated user already owns a task group with the identical name; retrying a creation after a previous success.","commonSituations":"Idempotency-unaware retry logic re-posting the same request; two admins creating similarly named groups; import scripts run twice without deduplication.","solutions":["Choose a unique name for the new task group (unique per user).","Query existing groups first and reuse/update the existing group instead of creating a new one.","Make creation idempotent by checking name existence before calling the API."],"exampleFix":"// before\napiClient.createTaskGroup(user, projectCode, \"etl-group\", desc, 10); // second run fails\n// after\nif (apiClient.findGroupByName(user, \"etl-group\") == null) {\n    apiClient.createTaskGroup(user, projectCode, \"etl-group\", desc, 10);\n}","handlingStrategy":"validation","validationCode":"boolean exists = api.listTaskGroups(u).stream()\n    .anyMatch(g -> g.getName().equals(name));\nif (exists) { /* reuse or rename before creating */ }","typeGuard":null,"tryCatchPattern":"try { api.createTaskGroup(u, pc, name, desc, size); }\ncatch (ServiceException e) { if (e.getCode() == 130001) { reuseOrCreateWithSuffix(name); } }","preventionTips":["Check name existence before create calls","Make creation scripts idempotent","Adopt naming conventions with unique suffixes per environment"],"tags":["duplicate","task-group","uniqueness"],"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"}