{"record":{"id":"4c52dfef71943906","repo":"OpenFeign/feign","slug":"type-must-be-an-interface-type","errorCode":null,"errorMessage":"Type must be an interface: ${type}","messagePattern":"Type must be an interface: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/feign/ReflectiveFeign.java","lineNumber":235,"sourceCode":"    }\n\n    private MethodHandler createMethodHandler(\n        final Target<?> target, final MethodMetadata md, final C requestContext) {\n      if (md.isIgnored()) {\n        return args -> {\n          throw new IllegalStateException(md.configKey() + \" is not a method handled by feign\");\n        };\n      }\n\n      return factory.create(target, md, requestContext);\n    }\n  }\n\n  private static class TargetSpecificationVerifier {\n    public static <T> void verify(Target<T> target) {\n      Class<T> type = target.type();\n      if (!type.isInterface()) {\n        throw new IllegalArgumentException(\"Type must be an interface: \" + type);\n      }\n\n      for (final Method m : type.getMethods()) {\n        final Class<?> retType = m.getReturnType();\n\n        if (!CompletableFuture.class.isAssignableFrom(retType)) {\n          continue; // synchronous case\n        }\n\n        if (retType != CompletableFuture.class) {\n          throw new IllegalArgumentException(\n              \"Method return type is not CompleteableFuture: \"\n                  + getFullMethodName(type, retType, m));\n        }\n\n        final Type genRetType = m.getGenericReturnType();\n\n        if (!(genRetType instanceof ParameterizedType)) {","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/core/src/main/java/feign/ReflectiveFeign.java#L217-L253","documentation":"Validation in TargetSpecificationVerifier.verify: the type of the given Target is not an interface, so Feign's dynamic-proxy-based client cannot be constructed. Feign creates a JDK Proxy over the target's interface; a class (or primitive/array) type is unsupported input and the target can never be instantiated.","triggerScenarios":"Thrown at core/src/main/java/feign/ReflectiveFeign.java:235 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define the API as an interface and point the Target at that interface type","Use Feign.builder().target(TypeApi.class, url) with an interface rather than a concrete class","If you have a concrete class, extract an interface for its remote methods","Check for accidental use of getClass() or an implementation type when constructing the Target"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}