{"record":{"id":"5b53c119edcca3dc","repo":"alibaba/nacos","slug":"unsupported-http-method","errorCode":null,"errorMessage":"Unsupported HTTP method: {}","messagePattern":"Unsupported HTTP method: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/remote/ClientHttpProxy.java","lineNumber":242,"sourceCode":"        \n        switch (request.getHttpMethod()) {\n            case HttpMethod.GET:\n                return nacosRestTemplate.get(url, httpConfig, httpHeaders, query, String.class);\n            case HttpMethod.POST:\n                if (StringUtils.isNotBlank(request.getBody())) {\n                    return nacosRestTemplate.postJson(url, httpHeaders, query, request.getBody(),\n                        String.class);\n                } else {\n                    return nacosRestTemplate.postForm(url, httpConfig, httpHeaders, paramValues,\n                        String.class);\n                }\n            case HttpMethod.PUT:\n                return nacosRestTemplate.putForm(url, httpConfig, httpHeaders, paramValues,\n                    String.class);\n            case HttpMethod.DELETE:\n                return nacosRestTemplate.delete(url, httpConfig, httpHeaders, query, String.class);\n            default:\n                throw new IllegalArgumentException(\n                    \"Unsupported HTTP method: \" + request.getHttpMethod());\n        }\n    }\n    \n    private static final String LINE_FEED = \"\\r\\n\";\n    \n    private static final String BOUNDARY_PREFIX = \"----NacosBoundary\";\n    \n    private HttpRestResult<String> executeMultipartPost(String url, HttpClientConfig httpConfig,\n        Header httpHeaders,\n        Query query, HttpRequest request) throws IOException {\n        String fullUrl = query != null && !query.isEmpty() ? url + \"?\" + query.toQueryUrl() : url;\n        String boundary = BOUNDARY_PREFIX + System.currentTimeMillis();\n        \n        java.net.URL urlObj = new java.net.URL(fullUrl);\n        HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\n        conn.setRequestMethod(HttpMethod.POST);\n        conn.setConnectTimeout(httpConfig.getConTimeOutMillis());","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/remote/ClientHttpProxy.java#L224-L260","documentation":"Thrown by ClientHttpProxy.executeHttpRequest as an IllegalArgumentException in the default branch of the HTTP method switch. It fires when the HttpRequest's HTTP method is not one of GET, POST (json/form/multipart), PUT, or DELETE. This is a programming error indicating an unsupported or misspelled HTTP method was set on the request.","triggerScenarios":"Building an HttpRequest with request.setHttpMethod() set to a value outside the supported set (GET, POST, PUT, DELETE) — e.g. PATCH, HEAD, OPTIONS, or a custom method string. The switch in executeHttpRequest has no case for it and falls to default.","commonSituations":"Custom plugin or extension code building an HttpRequest with PATCH or HEAD method. A bug where the HTTP method constant is set from an untrusted source. Version mismatch where a new method was expected but the proxy does not support it.","solutions":["Ensure the HttpRequest uses only GET, POST, PUT, or DELETE methods.","If PATCH or another method is genuinely needed, extend ClientHttpProxy or file a feature request — the current proxy does not support it.","Audit the code that constructs the HttpRequest to confirm the HTTP method is always from the supported HttpMethod constants."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Set<String> supported = Set.of(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE);\nif (!supported.contains(request.getHttpMethod())) {\n    throw new IllegalArgumentException(\"Unsupported HTTP method: \" + request.getHttpMethod());\n}","typeGuard":"boolean isSupportedHttpMethod(String method) {\n    return method != null && Set.of(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE)\n        .contains(method);\n}","tryCatchPattern":null,"preventionTips":["Only use HttpMethod constants (GET, POST, PUT, DELETE) when building requests for the maintainer client.","Do not source the HTTP method from untrusted or dynamic input without validation.","Remember the proxy does not support PATCH, HEAD, or OPTIONS."],"tags":["validation","maintainer-client","http-proxy","http-method","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}