{"record":{"id":"28d174833507dab5","repo":"alibaba/nacos","slug":"21006","errorCode":"21006","errorMessage":"not match any type of selector!","messagePattern":"not match any type of selector!","errorType":"validation","errorClass":"NacosApiException","httpStatus":400,"severity":"error","filePath":"naming/src/main/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3.java","lineNumber":231,"sourceCode":"        \n        return Result.success(\"ok\");\n    }\n    \n    private Selector parseSelector(String selectorJsonString) throws Exception {\n        if (StringUtils.isBlank(selectorJsonString)) {\n            return new NoneSelector();\n        }\n        \n        JsonNode selectorJson = JacksonUtils.toObj(URLDecoder.decode(selectorJsonString, \"UTF-8\"));\n        String type = Optional.ofNullable(selectorJson.get(\"type\")).orElseThrow(\n            () -> new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.SELECTOR_ERROR,\n                \"not match any type of selector!\"))\n            .asText();\n        String expression =\n            Optional.ofNullable(selectorJson.get(\"expression\")).map(JsonNode::asText).orElse(null);\n        Selector selector = selectorManager.parseSelector(type, expression);\n        if (Objects.isNull(selector)) {\n            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.SELECTOR_ERROR,\n                \"not match any type of selector!\");\n        }\n        \n        return selector;\n    }\n    \n    /**\n     * get subscriber list.\n     */\n    @Since(\"3.0.0\")\n    @GetMapping(\"/subscribers\")\n    @Secured(action = ActionTypes.READ, apiType = ApiType.ADMIN_API)\n    public Result<Page<SubscriberInfo>> subscribers(ServiceForm serviceForm, PageForm pageForm,\n        AggregationForm aggregationForm) throws Exception {\n        serviceForm.validate();\n        pageForm.validate();\n        int pageNo = pageForm.getPageNo();\n        int pageSize = pageForm.getPageSize();","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/naming/src/main/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3.java#L213-L249","documentation":"Thrown by ServiceControllerV3.parseSelector with ErrorCode.SELECTOR_ERROR=21006 (HTTP 400 INVALID_PARAM). There are two trigger points: (1) the selector JSON has no 'type' field at all, or (2) selectorManager.parseSelector() returns null because the 'type' value does not match any registered selector type. The registered types are keyed in SelectorManager.selectorTypes (typically 'none' and 'label', plus CMDB-provided types).","triggerScenarios":"Calling the service update API with a selectorJsonString that either (a) is a valid JSON object but lacks the 'type' field, or (b) has a 'type' value not in the SelectorManager's selectorTypes map (e.g. 'unknown', 'expression' when no such selector is registered).","commonSituations":"Using a CMDB selector type when the CMDB plugin is not installed/enabled. Misspelling the selector type (e.g. 'lable' instead of 'label'). Passing malformed selector JSON where the type field is nested incorrectly. Migrating from a version that supported a selector type that was removed.","solutions":["Ensure the selector JSON includes a 'type' field set to a registered value: 'none' for no filtering or 'label' for label-based selection.","If using a CMDB selector, confirm the CMDB plugin is installed and the selector type is registered in SelectorManager.","Validate the selector JSON structure: {\"type\": \"label\", \"expression\": \"...\"} before sending.","Use a blank/empty selectorJsonString to default to NoneSelector if no selector is needed."],"exampleFix":"// before\nString selectorJson = \"{\\\"expression\\\": \\\"key=value\\\"}\";\n\n// after\nString selectorJson = \"{\\\"type\\\": \\\"label\\\", \\\"expression\\\": \\\"key=value\\\"}\";","handlingStrategy":"validation","validationCode":"// validate selector JSON before sending to the server\nObjectMapper mapper = new ObjectMapper();\nJsonNode node = mapper.readTree(selectorJsonString);\nString type = node.has(\"type\") ? node.get(\"type\").asText() : null;\nif (type == null || !Set.of(\"none\", \"label\").contains(type)) {\n    throw new IllegalArgumentException(\"selector type must be 'none' or 'label', got: \" + type);\n}","typeGuard":"boolean isValidSelectorType(String type) {\n    return type != null && Set.of(\"none\", \"label\").contains(type.toLowerCase());\n}","tryCatchPattern":null,"preventionTips":["Always include a 'type' field in selector JSON; use 'none' when no selector is needed.","Pass a blank selectorJsonString to default to NoneSelector rather than sending partial JSON.","Confirm CMDB selector types are registered (plugin installed) before referencing them."],"tags":["naming","selector","validation","admin-api","cmdb"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}