alibaba/nacos · warning · NacosApiException
SELECTOR_ERROR
SELECTOR_ERROR
Error message
not match any type of selector!
What it means
Thrown by ConsoleServiceController during service-selector parsing when the selector JSON has no 'type' field, or when selectorManager.parseSelector(type, expression) returns null for an unrecognized type. It raises NacosApiException with NacosException.INVALID_PARAM (HTTP 400) and ErrorCode.SELECTOR_ERROR.
Source
Thrown at console/src/main/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleServiceController.java:266
clusterMetadata);
return Result.success("ok");
}
private Selector parseSelector(String selectorJsonString) throws Exception {
if (StringUtils.isBlank(selectorJsonString)) {
return new NoneSelector();
}
JsonNode selectorJson = JacksonUtils.toObj(URLDecoder.decode(selectorJsonString, "UTF-8"));
String type = Optional.ofNullable(selectorJson.get("type")).orElseThrow(
() -> new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.SELECTOR_ERROR,
"not match any type of selector!"))
.asText();
String expression =
Optional.ofNullable(selectorJson.get("expression")).map(JsonNode::asText).orElse(null);
Selector selector = selectorManager.parseSelector(type, expression);
if (Objects.isNull(selector)) {
throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.SELECTOR_ERROR,
"not match any type of selector!");
}
return selector;
}
}
View on GitHub (pinned to 9b989acdf1)
Solutions
- Ensure the selector JSON contains a 'type' field matching an installed selector type (call the selector-type list endpoint to see valid values).
- If no selector is wanted, pass the empty/null selector so the NoneSelector branch is used instead of malformed JSON.
- Validate the JSON is well formed and URL-decoded correctly before submission.
Example fix
// before
selectorJsonString = "{\"expression\":\"...\"}"; // no type
// after
selectorJsonString = "{\"type\":\"label\",\"expression\":\"...\"}"; Defensive patterns
Strategy: validation
Validate before calling
// Validate selector JSON before submitting it
if (selectorJsonString != null && !selectorJsonString.isBlank()) {
JsonNode node = JacksonUtils.toObj(URLDecoder.decode(selectorJsonString, "UTF-8"));
if (node.get("type") == null || node.get("type").asText().isBlank()) {
throw new IllegalArgumentException("selector JSON must include a non-empty 'type'");
}
} Type guard
// Java: guard that a selector type is present and known
boolean selectorValid = selectorNode.hasNonNull("type")
&& knownSelectorTypes.contains(selectorNode.get("type").asText()); Try / catch
try {
controller.createService(form);
} catch (NacosApiException e) {
if (e.getDetailErrCode() == ErrorCode.SELECTOR_ERROR.getCode()) {
form.setSelector(null); // fall back to NoneSelector
controller.createService(form);
} else { throw e; }
} Prevention
- Fetch valid selector types via the selector-type list endpoint before submitting.
- Include a 'type' field in every non-empty selector JSON.
- Send an empty/null selector when no routing is needed.
When it happens
Trigger: Creating/updating a service with a selector JSON string that is missing 'type', or whose 'type' does not correspond to any selector type the selectorManager knows (e.g., a type not returned by getSelectorTypeList).
Common situations: Hand-built selector JSON missing the type key; typo in the type value; using a selector type from a plugin that is not installed/enabled on this cluster.
Related errors
- 400
- The parameter 'regex' cannot be null.
- The parameter 'metadata' cannot be null.
- 21006
- PARAMETER_MISSING
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/f976374d9051b77c.
Report an issue: GitHub.