alibaba/nacos · error · IllegalArgumentException
Unsupported http method : {name}
Error message
Unsupported http method : {name} What it means
Thrown by BaseHttpMethod.sourceOf() as an IllegalArgumentException when the provided method name does not match any of the supported HTTP methods (case-insensitive). Supported methods: GET, GET_LARGE, POST, PUT, DELETE, DELETE_LARGE, HEAD, TRACE, PATCH, OPTIONS. This is used internally by the Nacos HTTP client to map method name strings to enum values.
Source
Thrown at common/src/main/java/com/alibaba/nacos/common/http/BaseHttpMethod.java:172
}
protected HttpUriRequestBase createRequest(String url) {
throw new UnsupportedOperationException();
}
/**
* Value of {@link BaseHttpMethod}.
*
* @param name method name
* @return {@link BaseHttpMethod}
*/
public static BaseHttpMethod sourceOf(String name) {
for (BaseHttpMethod method : BaseHttpMethod.values()) {
if (StringUtils.equalsIgnoreCase(name, method.name)) {
return method;
}
}
throw new IllegalArgumentException("Unsupported http method : " + name);
}
/**
* get Large implemented.
* <p>
* Mainly used for GET request parameters are relatively large, can not be placed on the URL, so it needs to be
* placed in the body.
* </p>
*/
public static class HttpGetWithEntity extends HttpUriRequestBase {
public static final String METHOD_NAME = "GET";
public HttpGetWithEntity(String url) {
super(METHOD_NAME, URI.create(url));
}
}
View on GitHub (pinned to 9b989acdf1)
Solutions
- Check the method name from the exception message and use one of the supported values: GET, POST, PUT, DELETE, HEAD, TRACE, PATCH, OPTIONS (or GET_LARGE / DELETE_LARGE for body-carrying variants).
- If you need CONNECT or a custom method, it is not supported by this enum-based dispatch; use the underlying Apache HttpClient directly.
Example fix
// before
BaseHttpMethod method = BaseHttpMethod.sourceOf("CONNECT");
// after
BaseHttpMethod method = BaseHttpMethod.sourceOf("POST"); Defensive patterns
Strategy: validation
Validate before calling
Set<String> validMethods = Set.of("GET", "GET_LARGE", "POST", "PUT", "DELETE",
"DELETE_LARGE", "HEAD", "TRACE", "PATCH", "OPTIONS");
if (!validMethods.contains(methodName.toUpperCase())) {
throw new IllegalArgumentException("Unsupported HTTP method: " + methodName
+ ". Supported: " + validMethods);
} Try / catch
try {
BaseHttpMethod method = BaseHttpMethod.sourceOf(name);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Unsupported http method")) {
// Default to GET or reject the request
method = BaseHttpMethod.GET;
} else {
throw e;
}
} Prevention
- Restrict HTTP method input to the supported set before calling sourceOf().
- Validate method names at the API boundary before they reach the Nacos HTTP client.
- Document the supported method names for consumers of your API.
When it happens
Trigger: Passing a method name like 'CONNECT', 'get_large' (wrong case handled but typo matters), or any non-standard HTTP verb to sourceOf(). A null input would cause a NullPointerException before reaching the throw.
Common situations: Custom HTTP interceptors or proxy layers injecting non-standard method names; typo in method configuration; outdated method names from older Nacos versions.
Related errors
- scope must be PUBLIC or PRIVATE
- Invalid Agent resource status: {status}
- httpClientFactory is null
- Illegal url path expression : {subPath}
- list size must be a multiple of 2
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/bb862a92099e75ec.
Report an issue: GitHub.