{"record":{"id":"d112b3803341a64b","repo":"apache/shenyu","slug":"the-namespace-s-does-not-exist","errorCode":null,"errorMessage":"The namespace(s) does not exist！","messagePattern":"The namespace\\(s\\) does not exist！","errorType":"validation","errorClass":"ShenyuAdminException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java","lineNumber":141,"sourceCode":"        }\n        if (CollectionUtils.isEmpty(namespaceIds)) {\n            return new CommonPager<>();\n        }\n        namespaceQuery.setNamespaceIds(namespaceIds);\n        return PageResultUtils.result(namespaceQuery.getPageParameter(), () -> namespaceMapper.countByQuery(namespaceQuery), () -> namespaceMapper.selectByQuery(namespaceQuery)\n                .stream()\n                .map(NamespaceTransfer.INSTANCE::mapToVo)\n                .collect(Collectors.toList()));\n    }\n\n    @Override\n    public String delete(final List<String> ids) {\n        if (ids.contains(Constants.DEFAULT_NAMESPACE_PRIMARY_KEY)) {\n            throw new ShenyuAdminException(AdminConstants.SYS_DEFAULT_NAMESPACE_ID_DELETE);\n        }\n        List<String> namespaceIdList = namespaceMapper.selectByIds(ids).stream().map(NamespaceDO::getNamespaceId).collect(Collectors.toList());\n        if (CollectionUtils.isEmpty(namespaceIdList)) {\n            throw new ShenyuAdminException(AdminConstants.SYS_NAMESPACE_ID_NOT_EXIST);\n        }\n        List<RuleDO> ruleDOList = ruleMapper.selectAllByNamespaceIds(namespaceIdList);\n        if (CollectionUtils.isNotEmpty(ruleDOList)) {\n            throw new ShenyuAdminException(\"rule exist under those namespace!\");\n        }\n        List<SelectorDO> selectorDOS = selectorMapper.selectAllByNamespaceIds(namespaceIdList);\n        if (CollectionUtils.isNotEmpty(selectorDOS)) {\n            throw new ShenyuAdminException(\"selector exist under those namespace!\");\n        }\n        List<NamespacePluginVO> namespacePluginVOS = namespacePluginRelMapper.selectAllByNamespaceIds(namespaceIdList);\n        if (CollectionUtils.isNotEmpty(namespacePluginVOS)) {\n            throw new ShenyuAdminException(\"Plugins exist under those namespace!\");\n        }\n        List<MetaDataDO> metaDataDOList = metaDataMapper.findAllByNamespaceIds(namespaceIdList);\n        if (CollectionUtils.isNotEmpty(metaDataDOList)) {\n            throw new ShenyuAdminException(\"metaData exist under those namespace!\");\n        }\n        List<AppAuthDO> appPathDOList = appAuthMapper.findByNamespaceIds(namespaceIdList);","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java#L123-L159","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nnamespaceService.delete(ids);\n// after\nList<NamespaceDTO> existing = namespaceService.findAll().stream()\n    .filter(n -> ids.contains(n.getId()))\n    .collect(Collectors.toList());\nif (!existing.isEmpty()) {\n    namespaceService.delete(existing.stream().map(NamespaceDTO::getId).collect(Collectors.toList()));\n}","handlingStrategy":"validation","validationCode":"List<NamespaceDO> existing = namespaceMapper.selectByIds(ids);\nif (existing.isEmpty()) {\n    throw new IllegalArgumentException(\"none of the namespace ids exist\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    namespaceService.delete(ids);\n} catch (ShenyuAdminException e) {\n    if (AdminConstants.SYS_NAMESPACE_ID_NOT_EXIST.equals(e.getMessage())) {\n        LOG.warn(\"namespaces already gone, nothing to delete\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["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"],"tags":["shenyu","admin","namespace","record-not-found"],"backgroundTag":"record-not-found","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}