{"record":{"id":"5ec5628776863dd2","repo":"apache/shenyu","slug":"doregister-failed-to-execute-because-selectordo-object-is","errorCode":null,"errorMessage":"doRegister Failed to execute, because selectorDO object is null, wait to retry.","messagePattern":"doRegister Failed to execute, because selectorDO object is null, wait to retry\\.","errorType":"exception","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/AbstractShenyuClientRegisterServiceImpl.java","lineNumber":204,"sourceCode":"    /**\n     * Register uri string.\n     *\n     * @param selectorName the selector name\n     * @param uriList      the uri list\n     * @param namespaceId  the namespace id\n     * @return the string\n     */\n    @Override\n    public String doRegisterURI(final String selectorName, final List<URIRegisterDTO> uriList, final String namespaceId) {\n        if (CollectionUtils.isEmpty(uriList)) {\n            return \"\";\n        }\n        String pluginName = PluginNameAdapter.rpcTypeAdapter(rpcType());\n        SelectorDO selectorDO = selectorService.findByNameAndPluginNameAndNamespaceId(selectorName, pluginName, namespaceId);\n        LOG.info(\"selector info params: selectorName: {}, pluginName: {}, namespaceId: {}, selectorDO info: {}.\",\n                selectorName, pluginName, namespaceId, selectorDO);\n        if (Objects.isNull(selectorDO)) {\n            throw new ShenyuException(\"doRegister Failed to execute, because selectorDO object is null, wait to retry.\");\n        }\n        this.checkNamespacePluginRel(namespaceId, pluginName);\n        // fetch UPSTREAM_MAP data from db\n        //upstreamCheckService.fetchUpstreamData();\n        //update upstream\n        List<URIRegisterDTO> validUriList = uriList.stream()\n                .filter(dto -> Objects.nonNull(dto.getPort()) && StringUtils.isNotBlank(dto.getHost()))\n                .collect(Collectors.toList());\n        String handler = buildHandle(validUriList, selectorDO);\n        if (Objects.nonNull(handler)) {\n            selectorDO.setHandle(handler);\n            SelectorData selectorData = selectorService.buildByNameAndPluginNameAndNamespaceId(selectorName, PluginNameAdapter.rpcTypeAdapter(rpcType()), namespaceId);\n            selectorData.setHandle(handler);\n            // update db\n            selectorService.updateSelective(selectorDO);\n            // publish change event.\n            doDiscoveryLocal(selectorDO, pluginName, validUriList);\n        }","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/AbstractShenyuClientRegisterServiceImpl.java#L186-L222","documentation":"doRegisterURI() throws ShenyuException when no SelectorDO exists for the given selectorName + pluginName + namespaceId. URI registration requires an existing selector to attach URIs to; the code intentionally aborts with 'wait to retry' because the selector is usually created by a preceding metadata registration that has not completed or synced yet.","triggerScenarios":"A backend client registers URIs (doRegisterURI) before the selector with that name exists in the database for the target namespace — e.g. heartbeat/URI registration racing ahead of metadata registration, or a wrong namespaceId so the selector lookup misses.","commonSituations":"Client SDK starts and registers URIs immediately on boot before metadata registration finishes; namespaceId mismatch between client config and admin; selector was deleted in the dashboard while clients keep re-registering; eventual consistency gap between admin replicas.","solutions":["Ensure the client performs metadata registration (which creates the selector) before URI/heartbeat registration.","Verify the client's namespaceId matches the namespace where the selector was created.","Retry — the message explicitly says 'wait to retry'; the Shenyu client registration is designed to retry.","Check the admin log line above the error ('selector info params: ...') to confirm which name/plugin/namespace was looked up and whether it exists in the selector table."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// client-side, before registering URIs\nSelectorDO selector = adminApi.findSelector(selectorName, pluginName, namespaceId);\nif (selector == null) { registerMetaDataFirst(); /* creates the selector */ }","typeGuard":null,"tryCatchPattern":"try {\n    registerService.doRegisterURI(selectorName, uriList, namespaceId);\n} catch (ShenyuException e) {\n    if (e.getMessage().contains(\"selectorDO object is null\")) {\n        retryWithBackoff(() -> registerService.doRegisterURI(selectorName, uriList, namespaceId));\n    } else { throw e; }\n}","preventionTips":["Sequence registrations: metadata (creates selector) before URI/heartbeat.","Keep namespaceId identical across all client registration calls.","Enable client-side retry for ShenyuException during startup registration.","Don't delete selectors in the dashboard while clients are actively registering against them."],"tags":["registration","selector","race-condition","namespace"],"backgroundTag":"entity-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"}