{"record":{"id":"a51b0e720bf542e1","repo":"OpenFeign/feign","slug":"invalid-http-method-method","errorCode":null,"errorMessage":"Invalid HTTP Method: ${method}","messagePattern":"Invalid HTTP Method: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/RequestTemplate.java","lineNumber":307,"sourceCode":"      throw new IllegalStateException(\"template has not been resolved.\");\n    }\n    return Request.create(this.method, this.url(), this.headers(), this.body, this);\n  }\n\n  /**\n   * Set the Http Method.\n   *\n   * @param method to use.\n   * @return a RequestTemplate for chaining.\n   * @deprecated see {@link RequestTemplate#method(HttpMethod)}\n   */\n  @Deprecated\n  public RequestTemplate method(String method) {\n    checkNotNull(method, \"method\");\n    try {\n      this.method = HttpMethod.valueOf(method);\n    } catch (IllegalArgumentException iae) {\n      throw new IllegalArgumentException(\"Invalid HTTP Method: \" + method);\n    }\n    return this;\n  }\n\n  /**\n   * Set the Http Method.\n   *\n   * @param method to use.\n   * @return a RequestTemplate for chaining.\n   */\n  public RequestTemplate method(HttpMethod method) {\n    checkNotNull(method, \"method\");\n    this.method = method;\n    return this;\n  }\n\n  /**\n   * The Request Http Method.","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/RequestTemplate.java#L289-L325","documentation":"RequestTemplate.method(String) parses the given string into an HttpMethod enum via HttpMethod.valueOf. If the string is not a valid HTTP method name, the resulting IllegalArgumentException is rethrown with 'Invalid HTTP Method: <method>'.","triggerScenarios":"Calling RequestTemplate.method(\"GETS\") or any string that is not a standard HTTP method token (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE) when building a template programmatically or via a misconfigured contract.","commonSituations":"Typo in a custom Contract/annotation parser, reading the HTTP verb from configuration or an annotation value with a typo, lowercasing methods before passing them in.","solutions":["Pass a standard uppercase HTTP method name, e.g. method(\"GET\")","Trim and normalize case: HttpMethod.valueOf(method.trim().toUpperCase()) before calling","Fix the annotation or config value supplying the method string","Prefer the typed method(HttpMethod) overload to get compile-time safety"],"exampleFix":"// before\ntemplate.method(\"Get\");\n// after\ntemplate.method(\"GET\"); // or template.method(HttpMethod.GET)","handlingStrategy":"validation","validationCode":"if (java.net.http.HttpMethod.includes == null) { /* Java 8-safe check */ }\njava.util.Set<String> VALID = java.util.Set.of(\"GET\",\"POST\",\"PUT\",\"DELETE\",\"PATCH\",\"HEAD\",\"OPTIONS\",\"TRACE\");\nif (!VALID.contains(method.trim().toUpperCase())) {\n  throw new IllegalArgumentException(\"Unsupported method: \" + method);\n}","typeGuard":null,"tryCatchPattern":"try {\n  template.method(name);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid HTTP Method\")) {\n    LOGGER.warn(\"Falling back to GET; invalid method {}\", name);\n    template.method(\"GET\");\n  } else { throw e; }\n}","preventionTips":["Use the typed method(HttpMethod) overload instead of strings","Normalize case and trim strings from config/annotations before use","Validate HTTP verbs from external config at load time"],"tags":["java","feign-client","http-method","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}