{"record":{"id":"f516aed4b1d9319a","repo":"apache/shenyu","slug":"plugins-exist-under-those-namespace","errorCode":null,"errorMessage":"Plugins exist under those namespace!","messagePattern":"Plugins exist under those namespace!","errorType":"exception","errorClass":"ShenyuAdminException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java","lineNumber":153,"sourceCode":"    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);\n        if (CollectionUtils.isNotEmpty(appPathDOList)) {\n            throw new ShenyuAdminException(\"appPath exist under those namespace!\");\n        }\n        namespaceMapper.deleteByIds(ids);\n        return ShenyuResultMessage.DELETE_SUCCESS;\n    }\n\n    @Override\n    public NamespaceVO findById(final String id) {\n        return NamespaceTransfer.INSTANCE.mapToVo(namespaceMapper.selectById(id));\n    }\n","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java#L135-L171","documentation":"ShenYu admin refuses to delete a namespace while plugin-to-namespace relations still exist. The delete flow checks selectors first, then namespacePluginRelMapper; if plugin relations exist under the target namespaces, deletion is aborted with this ShenyuAdminException to prevent orphaned plugin configuration.","triggerScenarios":"Calling NamespaceService.delete for a namespace that has plugin bindings (rows in the namespace-plugin relation table for those namespaceIds). Selectors must already be empty for the flow to reach this check.","commonSituations":"Deleting a namespace where plugins (e.g. divide, hystrix, logging plugins) were enabled per-namespace but no selectors/metadata remain; cleanup of test namespaces that had plugin configuration enabled.","solutions":["Remove the plugin-namespace relations first (disable/delete the plugin bindings for that namespace in the dashboard plugin config)","Delete plugin relations via the namespacePlugin API before calling delete","Inspect the plugin relation table for the namespaceIds and clear those rows, then retry"],"exampleFix":"// before\nnamespaceService.delete(Arrays.asList(\"ns-test\")); // throws: Plugins exist under those namespace!\n// after\nnamespacePluginService.deleteByNamespaceId(\"ns-test\"); // unbind plugins first\nnamespaceService.delete(Arrays.asList(\"ns-test\"));","handlingStrategy":"validation","validationCode":"if (namespacePluginRelMapper.selectAllByNamespaceIds(namespaceIds).isEmpty()) {\n    namespaceService.delete(namespaceIds);\n}","typeGuard":null,"tryCatchPattern":"try {\n    namespaceService.delete(namespaceIds);\n} catch (ShenyuAdminException e) {\n    if (e.getMessage().contains(\"Plugins exist\")) {\n        // unbind plugin relations for the namespace, then retry\n    } else {\n        throw e;\n    }\n}","preventionTips":["Disable per-namespace plugin bindings before deleting the namespace","Audit plugin-namespace relations during namespace decommissioning","Use the dashboard plugin page to confirm no plugins are attached to the target namespace"],"tags":["shenyu","admin","namespace","plugin-config","referential-integrity"],"backgroundTag":"invalid-state-transition","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"}