{"record":{"id":"42b7934e11c09e0b","repo":"OpenFeign/feign","slug":"request-with-non-absolute-url-not-supported-with-e","errorCode":null,"errorMessage":"Request with non-absolute URL not supported with empty target","messagePattern":"Request with non-absolute URL not supported with empty target","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/Target.java","lineNumber":175,"sourceCode":"    @Override\n    public Class<T> type() {\n      return type;\n    }\n\n    @Override\n    public String name() {\n      return name;\n    }\n\n    @Override\n    public String url() {\n      throw new UnsupportedOperationException(\"Empty targets don't have URLs\");\n    }\n\n    @Override\n    public Request apply(RequestTemplate input) {\n      if (input.url().indexOf(\"http\") != 0) {\n        throw new UnsupportedOperationException(\n            \"Request with non-absolute URL not supported with empty target\");\n      }\n      return input.request();\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n      if (obj instanceof EmptyTarget) {\n        EmptyTarget<?> other = (EmptyTarget) obj;\n        return type.equals(other.type) && name.equals(other.name);\n      }\n      return false;\n    }\n\n    @Override\n    public int hashCode() {\n      int result = 17;\n      result = 31 * result + type.hashCode();","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/Target.java#L157-L193","documentation":"EmptyTarget.apply() cannot resolve a request whose URL is relative, because with no target base URL there is nothing to resolve it against. Only template URLs that are already absolute (start with 'http') can be turned into a Request.","triggerScenarios":"Building a Feign client with Target.EmptyTarget.create(Interface.class) and invoking a method whose path is relative (e.g. \"/api/users\") without any interceptor or load-balancer rewriting the template to an absolute URL.","commonSituations":"Using EmptyTarget with client-side load balancing (Ribbon/feign-lb) but forgetting the RequestInterceptor that injects the host; misconfigured load-balancer target resolution; calling apply() manually in custom code.","solutions":["Ensure a RequestInterceptor or load balancer rewrites the template to an absolute http(s) URL before the request is built","Use HardCodedTarget with a base URL if no resolver exists","Check that the load-balancer dependency and Targeter configuration are active","Verify the interface method paths don't accidentally omit the scheme when using EmptyTarget"],"exampleFix":"// before\nMyApi api = Feign.builder().target(Target.EmptyTarget.create(MyApi.class)); // path \"/foo\" -> exception\n// after\nMyApi api = Feign.builder().requestInterceptor(t -> t.header(\"Host\", \"svc\")).target(Target.EmptyTarget.create(MyApi.class)); // or use HardCodedTarget(\"svc\", \"http://host\")","handlingStrategy":"validation","validationCode":"String url = template.url();\nif (usingEmptyTarget && !url.startsWith(\"http\")) throw new IllegalStateException(\"path must be absolute with EmptyTarget: \" + url);","typeGuard":"boolean isAbsolute(String u) { return u != null && (u.startsWith(\"http://\") || u.startsWith(\"https://\")); }","tryCatchPattern":"try { req = emptyTarget.apply(template); } catch (UnsupportedOperationException e) { throw new IllegalStateException(\"Configure a host interceptor/load balancer for EmptyTarget\", e); }","preventionTips":["Pair EmptyTarget with a RequestInterceptor or load balancer that injects the host","Otherwise use HardCodedTarget with a base URL","Verify load-balancer/Targeter configuration at startup","Add a startup check that the first request URL is absolute"],"tags":["target","empty-target","absolute-url","load-balancer","java"],"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"}