{"record":{"id":"ff75d115607a93b0","repo":"OpenFeign/feign","slug":"target-values-must-be-absolute","errorCode":null,"errorMessage":"target values must be absolute.","messagePattern":"target values must be absolute\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/RequestTemplate.java","lineNumber":508,"sourceCode":"    }\n    return this;\n  }\n\n  /**\n   * Set the target host for this request.\n   *\n   * @param target host for this request. Must be an absolute target.\n   * @return a RequestTemplate for chaining.\n   */\n  public RequestTemplate target(String target) {\n    /* target can be empty */\n    if (Util.isBlank(target)) {\n      return this;\n    }\n\n    /* verify that the target contains the scheme, host and port */\n    if (!UriUtils.isAbsolute(target)) {\n      throw new IllegalArgumentException(\"target values must be absolute.\");\n    }\n    if (target.endsWith(\"/\")) {\n      target = target.substring(0, target.length() - 1);\n    }\n    try {\n      /* parse the target */\n      URI targetUri = URI.create(target);\n\n      if (Util.isNotBlank(targetUri.getRawQuery())) {\n        /*\n         * target has a query string, we need to make sure that they are recorded as queries\n         */\n        this.extractQueryTemplates(targetUri.getRawQuery(), true);\n      }\n\n      /* strip the query string */\n      this.target =\n          targetUri.getScheme() + \"://\" + targetUri.getRawAuthority() + targetUri.getRawPath();","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/RequestTemplate.java#L490-L526","documentation":"RequestTemplate.target(String) sets the request base and requires an absolute URL containing scheme, host and port. This IllegalArgumentException is thrown when a relative value like '/api' is passed to target().","triggerScenarios":"Calling template.target(\"/api\") or target(\"localhost:8080\") — UriUtils.isAbsolute fails because there is no scheme — during manual template building or via Feign.builder().target(...) paths that call insert/create/apply.","commonSituations":"Configuring only a path as the base URL, environment config missing the scheme (e.g. BASE_URL=api.example.com without https://), misconfigured Target implementations.","solutions":["Include scheme and authority: target(\"https://api.example.com\")","Fix the base-url configuration value to start with http:// or https://","If only a path is needed, use uri() instead of target()","Validate configured URLs with UriUtils.isAbsolute before passing them in"],"exampleFix":"// before\ntemplate.target(\"api.example.com\");\n// after\ntemplate.target(\"https://api.example.com\");","handlingStrategy":"validation","validationCode":"if (baseUrl == null || !feign.template.UriUtils.isAbsolute(baseUrl)) {\n  throw new IllegalArgumentException(\"Base URL must be absolute, got: \" + baseUrl);\n}","typeGuard":null,"tryCatchPattern":"try {\n  template.target(baseUrl);\n} catch (IllegalArgumentException e) {\n  if (\"target values must be absolute.\".equals(e.getMessage())) {\n    throw new ConfigurationException(\"BASE_URL must include scheme, e.g. https://host: \" + baseUrl, e);\n  }\n  throw e;\n}","preventionTips":["Always include http:// or https:// in configured base URLs","Validate env/config URLs at application startup with UriUtils.isAbsolute","Default missing schemes explicitly rather than silently"],"tags":["java","feign-client","url","configuration"],"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"}