apache/shenyu · error · ShenyuAdminException
The namespace(s) does not exist!
Error message
The namespace(s) does not exist!
What it means
Thrown by NamespaceServiceImpl.delete when none of the supplied ids resolve to existing namespace rows: namespaceMapper.selectByIds returns empty, so the derived namespaceId list is empty and SYS_NAMESPACE_ID_NOT_EXIST is raised. It signals the delete batch refers entirely to non-existent namespaces.
Solutions
- Verify the ids are row primary keys from GET /namespace, not business namespaceId values
- Re-fetch the namespace list and delete only ids that still exist
- Make batch deletion tolerant: check existence first and skip missing ids
- Refresh UI state and retry with valid ids
Example fix
// before
namespaceService.delete(ids);
// after
List<NamespaceDTO> existing = namespaceService.findAll().stream()
.filter(n -> ids.contains(n.getId()))
.collect(Collectors.toList());
if (!existing.isEmpty()) {
namespaceService.delete(existing.stream().map(NamespaceDTO::getId).collect(Collectors.toList()));
} Defensive patterns
Strategy: validation
Validate before calling
List<NamespaceDO> existing = namespaceMapper.selectByIds(ids);
if (existing.isEmpty()) {
throw new IllegalArgumentException("none of the namespace ids exist");
} Try / catch
try {
namespaceService.delete(ids);
} catch (ShenyuAdminException e) {
if (AdminConstants.SYS_NAMESPACE_ID_NOT_EXIST.equals(e.getMessage())) {
LOG.warn("namespaces already gone, nothing to delete");
} else {
throw e;
}
} Prevention
- Use row primary keys from the namespace list API, not business namespaceId strings
- Re-fetch ids before batch delete to avoid stale references
- Handle already-deleted namespaces as no-ops in scripts
When it happens
Trigger: Calling DELETE /namespace with ids that were already deleted, fabricated ids, or primary-key values confused with namespaceId strings (the mapper selects by primary key id, not by the business namespaceId field).
Common situations: Passing business namespaceId (e.g. a UUID string) instead of the row primary key; retrying a delete after it already succeeded; stale dashboard state after concurrent deletion by another admin.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- shenyu this discovery is not found in current namespace
- The default namespace cannot delete!
- rule exist under those namespace!
- selector exist under those namespace!
- Plugins exist under those namespace!
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/d112b3803341a64b.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java:141
}
if (CollectionUtils.isEmpty(namespaceIds)) {
return new CommonPager<>();
}
namespaceQuery.setNamespaceIds(namespaceIds);
return PageResultUtils.result(namespaceQuery.getPageParameter(), () -> namespaceMapper.countByQuery(namespaceQuery), () -> namespaceMapper.selectByQuery(namespaceQuery)
.stream()
.map(NamespaceTransfer.INSTANCE::mapToVo)
.collect(Collectors.toList()));
}
@Override
public String delete(final List<String> ids) {
if (ids.contains(Constants.DEFAULT_NAMESPACE_PRIMARY_KEY)) {
throw new ShenyuAdminException(AdminConstants.SYS_DEFAULT_NAMESPACE_ID_DELETE);
}
List<String> namespaceIdList = namespaceMapper.selectByIds(ids).stream().map(NamespaceDO::getNamespaceId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(namespaceIdList)) {
throw new ShenyuAdminException(AdminConstants.SYS_NAMESPACE_ID_NOT_EXIST);
}
List<RuleDO> ruleDOList = ruleMapper.selectAllByNamespaceIds(namespaceIdList);
if (CollectionUtils.isNotEmpty(ruleDOList)) {
throw new ShenyuAdminException("rule exist under those namespace!");
}
List<SelectorDO> selectorDOS = selectorMapper.selectAllByNamespaceIds(namespaceIdList);
if (CollectionUtils.isNotEmpty(selectorDOS)) {
throw new ShenyuAdminException("selector exist under those namespace!");
}
List<NamespacePluginVO> namespacePluginVOS = namespacePluginRelMapper.selectAllByNamespaceIds(namespaceIdList);
if (CollectionUtils.isNotEmpty(namespacePluginVOS)) {
throw new ShenyuAdminException("Plugins exist under those namespace!");
}
List<MetaDataDO> metaDataDOList = metaDataMapper.findAllByNamespaceIds(namespaceIdList);
if (CollectionUtils.isNotEmpty(metaDataDOList)) {
throw new ShenyuAdminException("metaData exist under those namespace!");
}
List<AppAuthDO> appPathDOList = appAuthMapper.findByNamespaceIds(namespaceIdList);View on GitHub (pinned to 567142e072)