apache/dolphinscheduler · error · ServiceException
1402001
1402001
Error message
The Worker group [{0}] not exists What it means
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.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java:139
throw new ServiceException(Status.NAME_NULL);
}
checkWorkerGroupAddrList(addrList);
final Date now = new Date();
final WorkerGroup workerGroup;
try {
if (id == 0) {
// insert
workerGroup = new WorkerGroup();
workerGroup.setCreateTime(now);
workerGroup.setName(name);
workerGroup.setAddrList(addrList);
workerGroup.setUpdateTime(now);
workerGroup.setDescription(description);
workerGroupDao.insert(workerGroup);
} else {
workerGroup = workerGroupDao.queryById(id);
if (workerGroup == null) {
throw new ServiceException(Status.WORKER_GROUP_NOT_EXIST, id);
}
workerGroup.setName(name);
workerGroup.setAddrList(addrList);
workerGroup.setUpdateTime(now);
workerGroup.setDescription(description);
workerGroupDao.updateById(workerGroup);
log.info("Update worker group: {} success .", workerGroup);
}
boardCastToMasterThatWorkerGroupChanged();
return workerGroup;
} catch (DuplicateKeyException duplicateKeyException) {
throw new ServiceException(Status.NAME_EXIST, name);
}
}
/**
* check if the worker group has any dependent tasks, schedulers or environments;
* throws ServiceException with the matching status if any dependency is found.View on GitHub (pinned to 02eac45a1b)
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.
Example fix
// before workerGroupService.saveWorkerGroup(loginUser, 999, "grp", "ip:1234", ""); // deleted id // after WorkerGroup existing = workerGroupService.queryByName(loginUser, "grp"); int id = (existing == null) ? 0 : existing.getId(); workerGroupService.saveWorkerGroup(loginUser, id, "grp", "ip:1234", "");
Defensive patterns
Strategy: validation
Validate before calling
WorkerGroup g = workerGroupDao.queryById(id);
if (id != 0 && g == null) {
throw new IllegalArgumentException("worker group id " + id + " does not exist");
} Try / catch
try {
workerGroupService.saveWorkerGroup(loginUser, id, name, addrList, desc);
} catch (ServiceException e) {
if (e.getCode() == 1402001) { /* stale id: refresh list and retry */ }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/005bc4dc17fe00b2.
Report an issue: GitHub.