apache/shenyu · error · ShenyuAdminException
namespace is not exist
Error message
namespace is not exist
What it means
NamespaceServiceImpl.update requires a NamespaceDTO carrying a namespaceId to identify the row to modify. When the DTO is null or its namespaceId is null, the method throws "namespace is not exist" because it cannot locate or address any existing namespace to update.
Solutions
- Set namespaceId on the NamespaceDTO before calling createOrUpdate/update
- Ensure the HTTP request body includes the namespaceId field with the exact expected key
- Verify the client is targeting an existing namespace and passing its identifier, not a fresh DTO
- Null-check the DTO and its namespaceId at the controller/caller level to fail with a clearer validation message
Example fix
// before
NamespaceDTO dto = new NamespaceDTO();
dto.setName("prod");
namespaceService.createOrUpdate(dto); // throws: namespace is not exist
// after
NamespaceDTO dto = new NamespaceDTO();
dto.setNamespaceId("2a4d1c9f-ns-id"); // existing namespace identifier
dto.setName("prod");
namespaceService.createOrUpdate(dto); Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(namespaceDTO, "namespaceDTO must not be null"); Objects.requireNonNull(namespaceDTO.getNamespaceId(), "namespaceId is required for update"); namespaceService.createOrUpdate(namespaceDTO);
Type guard
boolean isUpdatable(NamespaceDTO dto) {
return dto != null && dto.getNamespaceId() != null && !dto.getNamespaceId().isEmpty();
} Try / catch
try {
namespaceService.createOrUpdate(namespaceDTO);
} catch (ShenyuAdminException e) {
if ("namespace is not exist".equals(e.getMessage())) {
throw new IllegalArgumentException("namespaceId is required to update a namespace", e);
}
throw e;
} Prevention
- Always populate namespaceId when constructing a NamespaceDTO for updates
- Validate the update payload at the controller layer before invoking the service
- Distinguish create vs update flows: only updates require a pre-existing namespaceId
- After version upgrades, verify request body field names still map to namespaceId
When it happens
Trigger: Calling createOrUpdate (which delegates to private update) with a NamespaceDTO that is null, or a NamespaceDTO whose getNamespaceId() returns null — e.g. building the DTO without setting namespaceId, or deserializing a request body missing the namespaceId field.
Common situations: Dashboard/API clients sending an update payload without namespaceId; code that reuses a creation-style DTO (no id) for updates; deserialization dropping the id field due to renamed/mismatched JSON keys after a version upgrade.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- shenyu this discovery is not found in current namespace
- The default namespace cannot delete!
- The namespace(s) does not exist!
- rule exist under those namespace!
- selector exist under those namespace!
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/46c1fe2adb9bc26a.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java:226
String namespaceId = StringUtils.defaultString(namespaceDTO.getNamespaceId(), NamespaceIDUtils.getInstance().generateNamespaceID());
NamespaceDO namespaceDO = NamespaceDO.builder()
.id(id)
.namespaceId(namespaceId)
.name(namespaceDTO.getName())
.description(namespaceDTO.getDescription())
.dateCreated(currentTime)
.dateUpdated(currentTime)
.build();
namespaceMapper.insert(namespaceDO);
namespaceEventPublisher.publish(new NamespaceCreatedEvent(namespaceDO, SessionUtil.visitorId()));
return NamespaceTransfer.INSTANCE.mapToVo(namespaceDO);
}
private NamespaceVO update(final NamespaceDTO namespaceDTO) {
if (Objects.isNull(namespaceDTO) || Objects.isNull(namespaceDTO.getNamespaceId())) {
throw new ShenyuAdminException("namespace is not exist");
}
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
NamespaceDO namespaceDO = NamespaceDO.builder()
.namespaceId(namespaceDTO.getNamespaceId())
.name(namespaceDTO.getName())
.description(namespaceDTO.getDescription())
.dateUpdated(currentTime)
.build();
return namespaceMapper.updateSelective(namespaceDO) > 0
? NamespaceTransfer.INSTANCE.mapToVo(namespaceDO) : null;
}
}
View on GitHub (pinned to 567142e072)