{"record":{"id":"005bc4dc17fe00b2","repo":"apache/dolphinscheduler","slug":"1402001","errorCode":"1402001","errorMessage":"The Worker group [{0}] not exists","messagePattern":"The Worker group \\[(.+?)\\] not exists","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java","lineNumber":139,"sourceCode":"            throw new ServiceException(Status.NAME_NULL);\n        }\n        checkWorkerGroupAddrList(addrList);\n        final Date now = new Date();\n        final WorkerGroup workerGroup;\n        try {\n            if (id == 0) {\n                // insert\n                workerGroup = new WorkerGroup();\n                workerGroup.setCreateTime(now);\n                workerGroup.setName(name);\n                workerGroup.setAddrList(addrList);\n                workerGroup.setUpdateTime(now);\n                workerGroup.setDescription(description);\n                workerGroupDao.insert(workerGroup);\n            } else {\n                workerGroup = workerGroupDao.queryById(id);\n                if (workerGroup == null) {\n                    throw new ServiceException(Status.WORKER_GROUP_NOT_EXIST, id);\n                }\n                workerGroup.setName(name);\n                workerGroup.setAddrList(addrList);\n                workerGroup.setUpdateTime(now);\n                workerGroup.setDescription(description);\n                workerGroupDao.updateById(workerGroup);\n                log.info(\"Update worker group: {} success .\", workerGroup);\n            }\n            boardCastToMasterThatWorkerGroupChanged();\n            return workerGroup;\n        } catch (DuplicateKeyException duplicateKeyException) {\n            throw new ServiceException(Status.NAME_EXIST, name);\n        }\n    }\n\n    /**\n     * check if the worker group has any dependent tasks, schedulers or environments;\n     * throws ServiceException with the matching status if any dependency is found.","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java#L121-L157","documentation":"Status.WORKER_GROUP_NOT_EXIST (1402001) is thrown when saving an existing worker group (id != 0) whose id does not match any row: workerGroupDao.queryById(id) returns null. It signals an update against a stale or fabricated worker-group id.","triggerScenarios":"Calling the save worker-group endpoint with an id of a group that was deleted (perhaps by another admin or a dependent-task cleanup), or with an arbitrary/incorrect id in a script.","commonSituations":"UI tab left open while another user deleted the group; scripts hard-coding ids copied from a different environment's database; id=0 vs real-id confusion (id==0 means create, not update).","solutions":["Re-fetch the worker-group list and use a current, valid id for updates.","Use id=0 (omit id) to create a new group instead of updating a non-existent one.","If the group was deleted intentionally, don't re-save it — recreate with the desired config.","Verify you're operating against the correct environment's database."],"exampleFix":"// before\nworkerGroupService.saveWorkerGroup(loginUser, 999, \"grp\", \"ip:1234\", \"\"); // deleted id\n// after\nWorkerGroup existing = workerGroupService.queryByName(loginUser, \"grp\");\nint id = (existing == null) ? 0 : existing.getId();\nworkerGroupService.saveWorkerGroup(loginUser, id, \"grp\", \"ip:1234\", \"\");","handlingStrategy":"validation","validationCode":"WorkerGroup g = workerGroupDao.queryById(id);\nif (id != 0 && g == null) {\n    throw new IllegalArgumentException(\"worker group id \" + id + \" does not exist\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    workerGroupService.saveWorkerGroup(loginUser, id, name, addrList, desc);\n} catch (ServiceException e) {\n    if (e.getCode() == 1402001) { /* stale id: refresh list and retry */ }\n}","preventionTips":["Refresh the worker-group list before updates instead of caching ids","Use id=0 to create, real ids only for confirmed existing groups","Handle concurrent deletions by re-fetching on 1402001 and retrying","Verify environment/database consistency when ids come from exports"],"tags":["worker-group","not-found","api"],"backgroundTag":"entity-not-found","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"}