alibaba/nacos · warning · NacosRuntimeException
404
404
Error message
Invalid URI
What it means
Thrown when request.getRequestURI() cannot be parsed by new URI(...).getPath() because the raw request URI violates RFC 2396 syntax (URISyntaxException). Returned as a 404 NacosRuntimeException (NacosException.NOT_FOUND) from the legacy resolver's getPath helper.
Source
Thrown at core/src/main/java/com/alibaba/nacos/core/code/ControllerMethodsCache.java:220
}
private String stripContextPath(String path, String contextPath) {
if (StringUtils.isEmpty(path) || StringUtils.isEmpty(contextPath)) {
return path;
}
if (path.startsWith(contextPath)) {
String stripped = path.substring(contextPath.length());
return StringUtils.isEmpty(stripped) ? StringUtils.EMPTY : stripped;
}
return path;
}
private String getPath(HttpServletRequest request) {
try {
return new URI(request.getRequestURI()).getPath();
} catch (URISyntaxException e) {
LOGGER.error("parse request to path error", e);
throw new NacosRuntimeException(NacosException.NOT_FOUND, "Invalid URI");
}
}
private List<RequestMappingInfo> findMatchedInfo(List<RequestMappingInfo> requestMappingInfos,
HttpServletRequest request) {
List<RequestMappingInfo> matchedInfo = new ArrayList<>();
for (RequestMappingInfo requestMappingInfo : requestMappingInfos) {
ParamRequestCondition matchingCondition = requestMappingInfo.getParamRequestCondition()
.getMatchingCondition(request);
if (matchingCondition != null) {
matchedInfo.add(requestMappingInfo);
}
}
return matchedInfo;
}
/**
* find target method from this package.View on GitHub (pinned to 9b989acdf1)
Solutions
- URL-encode the request path correctly on the client side (spaces -> %20, etc.).
- Fix the reverse proxy (nginx/ingress) to pass a well-formed, percent-encoded request URI.
- If the legacy resolver is not required, run without it (default) so this getPath() path is not exercised.
Example fix
// before GET /v3/admin/ns/instance?serviceName=a b HTTP/1.1 // after (encode the value) GET /v3/admin/ns/instance?serviceName=a%20b HTTP/1.1
Defensive patterns
Strategy: validation
Validate before calling
String raw = request.getRequestURI();
try { new URI(raw).getPath(); }
catch (URISyntaxException e) { /* reject 400 at the proxy/gateway before it reaches Nacos */ } Try / catch
try {
controllerMethodsCache.getMethod(request);
} catch (NacosRuntimeException e) {
if (e.getErrCode() == NacosException.NOT_FOUND) { /* invalid URI from client */ }
} Prevention
- URL-encode request paths on the client.
- Configure the reverse proxy to forward well-formed, percent-encoded URIs.
When it happens
Trigger: A client sends a request line whose URI contains characters/structure that java.net.URI rejects — unencoded spaces, mismatched brackets, illegal escape sequences, or a malformed proxy-generated URI reaching the legacy resolver.
Common situations: Reverse proxy misconfiguration that forwards an unescaped/mangled request URI; a hand-crafted HTTP request with an invalid target; URL-encoding bugs in a client SDK that leave reserved characters unencoded.
Related errors
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/80047aeaa31947d7.
Report an issue: GitHub.