{"record":{"id":"34a25195650f16ee","repo":"OpenFeign/feign","slug":"url-values-must-be-not-be-absolute","errorCode":null,"errorMessage":"url values must be not be absolute.","messagePattern":"url values must be not be absolute\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/RequestTemplate.java","lineNumber":450,"sourceCode":"   *\n   * @param uri to use, must be a relative uri.\n   * @return a RequestTemplate for chaining.\n   */\n  public RequestTemplate uri(String uri) {\n    return this.uri(uri, false);\n  }\n\n  /**\n   * Set the uri for the request.\n   *\n   * @param uri to use, must be a relative uri.\n   * @param append if the uri should be appended, if the uri is already set.\n   * @return a RequestTemplate for chaining.\n   */\n  public RequestTemplate uri(String uri, boolean append) {\n    /* validate and ensure that the url is always a relative one */\n    if (UriUtils.isAbsolute(uri)) {\n      throw new IllegalArgumentException(\"url values must be not be absolute.\");\n    }\n\n    if (uri == null) {\n      uri = \"/\";\n    } else if ((!uri.isEmpty()\n        && !uri.startsWith(\"/\")\n        && !uri.startsWith(\"{\")\n        && !uri.startsWith(\"?\")\n        && !uri.startsWith(\";\"))) {\n      /* if the start of the url is a literal, it must begin with a slash. */\n      uri = \"/\" + uri;\n    }\n\n    int fragmentIndex = uri.indexOf('#');\n    if (fragmentIndex > -1) {\n      fragment = uri.substring(fragmentIndex);\n      uri = uri.substring(0, fragmentIndex);\n    }","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/RequestTemplate.java#L432-L468","documentation":"RequestTemplate.uri(String, boolean) only accepts relative URIs because the absolute base (scheme, host, port) is supplied separately via target(). This IllegalArgumentException is thrown when an absolute URL like 'https://host/path' is passed to uri().","triggerScenarios":"Calling template.uri(\"https://api.example.com/users\") — UriUtils.isAbsolute detects the scheme and throws; also triggered indirectly via append/uri overloads with absolute values.","commonSituations":"Passing a full URL from configuration into uri() instead of target(), concatenating base URL and path then feeding the result to uri(), hardcoding absolute endpoints in templates.","solutions":["Split the URL: put 'https://api.example.com' in target() and '/users' in uri()","Strip the scheme+authority before passing to uri()","Use RequestTemplate.target(absoluteUrl) for the base and keep the path relative","In Target implementations, ensure the path returned is relative (Target.EmptyTarget/HardCodedTarget patterns)"],"exampleFix":"// before\ntemplate.uri(\"https://api.example.com/users\");\n// after\ntemplate.target(\"https://api.example.com\").uri(\"/users\");","handlingStrategy":"validation","validationCode":"if (feign.Util.isNotBlank(uri) && feign.template.UriUtils.isAbsolute(uri)) {\n  throw new IllegalArgumentException(\"Use target() for absolute URLs: \" + uri);\n}","typeGuard":null,"tryCatchPattern":"try {\n  template.uri(path);\n} catch (IllegalArgumentException e) {\n  if (\"url values must be not be absolute.\".equals(e.getMessage())) {\n    java.net.URI u = java.net.URI.create(path);\n    template.target(u.getScheme() + \"://\" + u.getRawAuthority()).uri(u.getRawPath());\n  } else { throw e; }\n}","preventionTips":["Keep base URL in target(), paths in uri()","Strip scheme+authority from user-supplied URLs before calling uri()","Add a config validator that rejects absolute URLs in path settings"],"tags":["java","feign-client","uri","invalid-argument"],"backgroundTag":"invalid-url","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"}