{"record":{"id":"46a070d6abd37149","repo":"OpenFeign/feign","slug":"template-has-not-been-resolved","errorCode":null,"errorMessage":"template has not been resolved.","messagePattern":"template has not been resolved\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/RequestTemplate.java","lineNumber":289,"sourceCode":"   * @deprecated use {@link RequestTemplate#resolve(Map)}. Values already encoded are recognized as\n   *     such and skipped.\n   */\n  @SuppressWarnings(\"unused\")\n  @Deprecated\n  RequestTemplate resolve(Map<String, ?> unencoded, Map<String, Boolean> alreadyEncoded) {\n    return this.resolve(unencoded);\n  }\n\n  /**\n   * Creates a {@link Request} from this template. The template must be resolved before calling this\n   * method, or an {@link IllegalStateException} will be thrown.\n   *\n   * @return a new Request instance.\n   * @throws IllegalStateException if this template has not been resolved.\n   */\n  public Request request() {\n    if (!this.resolved) {\n      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);","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/RequestTemplate.java#L271-L307","documentation":"RequestTemplate.request() builds the immutable Request, but only after the template has been resolved (URI template variables substituted). This IllegalStateException is thrown when request() is called on a template that still contains unresolved placeholders.","triggerScenarios":"Calling requestTemplate.request() (directly or via apply()/toString() paths that require a resolved template) before invoking resolve(Map<String,Object>) or executeAndDecode — i.e. building the Request manually while template variables remain unsubstituted.","commonSituations":"Custom Client or interceptor code reading template.request() too early, unit tests asserting on the Request before resolving, or using the deprecated apply() flow out of order.","solutions":["Call template.resolve(variables) (or let Feign's SynchronousMethodHandler do it) before calling request()","If you only need the unresolved URL string, use the template's url/toString() for diagnostics instead of request()","In custom interceptors, operate on the already-resolved Request (targetRequest) rather than the raw template","Ensure your code path does not skip TargetRequestTemplate resolution steps"],"exampleFix":"// before\nRequest req = template.request(); // IllegalStateException\n// after\nRequest req = template.resolve(Collections.singletonMap(\"id\", \"42\")).request();","handlingStrategy":"type-guard","validationCode":"if (!template.isResolved()) {\n  throw new IllegalStateException(\"Call resolve() before request()\");\n}","typeGuard":"boolean usable = template.isResolved(); // only build a Request when true","tryCatchPattern":"try {\n  Request req = template.request();\n} catch (IllegalStateException e) {\n  if (\"template has not been resolved.\".equals(e.getMessage())) {\n    template = template.resolve(myVariables);\n    Request req = template.request();\n  } else { throw e; }\n}","preventionTips":["Always call resolve() (or go through Feign's normal execution path) before request()","In custom clients, consume the resolved Request from the invocation context, not the raw template","Write tests that exercise the full template lifecycle","Avoid the deprecated apply() flow"],"tags":["java","feign-client","request-template","lifecycle"],"backgroundTag":"invalid-state-transition","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"}