{"record":{"id":"37a2a0944c467187","repo":"OpenFeign/feign","slug":"cannot-decode-type-type-gettypename","errorCode":null,"errorMessage":"Cannot decode type: ${type.getTypeName()}","messagePattern":"Cannot decode type: (.+?)","errorType":"exception","errorClass":"DecodeException","httpStatus":500,"severity":"error","filePath":"jackson-jr/src/main/java/feign/jackson/jr/JacksonJrDecoder.java","lineNumber":116,"sourceCode":"  }\n\n  protected Transformer findTransformer(Response response, Type type) {\n    if (type instanceof ParameterizedType) {\n      Type rawType = ((ParameterizedType) type).getRawType();\n      Type[] parameterType = ((ParameterizedType) type).getActualTypeArguments();\n      if (rawType.equals(List.class)) {\n        return (mapper, reader) -> mapper.listOfFrom((Class<?>) parameterType[0], reader);\n      }\n      if (rawType.equals(Map.class)) {\n        return (mapper, reader) -> mapper.mapOfFrom((Class<?>) parameterType[1], reader);\n      }\n      type = rawType;\n    }\n    if (type instanceof Class) {\n      Class<?> clazz = (Class<?>) type;\n      return (mapper, reader) -> mapper.beanFrom(clazz, reader);\n    }\n    throw new DecodeException(500, \"Cannot decode type: \" + type.getTypeName(), response.request());\n  }\n\n  @Override\n  public Object convert(Object object, Type type) throws IOException {\n    String json = mapper.asString(object);\n    if (type instanceof ParameterizedType) {\n      ParameterizedType pt = (ParameterizedType) type;\n      Type rawType = pt.getRawType();\n      Type[] args = pt.getActualTypeArguments();\n      if (rawType.equals(List.class)) {\n        return mapper.listOfFrom((Class<?>) args[0], json);\n      }\n      if (rawType.equals(Map.class)) {\n        return mapper.mapOfFrom((Class<?>) args[1], json);\n      }\n      type = rawType;\n    }\n    if (type instanceof Class) {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/jackson-jr/src/main/java/feign/jackson/jr/JacksonJrDecoder.java#L98-L134","documentation":"JacksonJrDecoder.findTransformer only knows how to decode into plain Java bean classes (or handled wrapper types); when the resolved type is neither, it throws DecodeException with the unsupported type name. jackson-jr's beanFrom requires a concrete Class, so generic or exotic types cannot be decoded by this decoder.","triggerScenarios":"Declaring a Feign method returning a non-bean type such as Object, an interface without a concrete impl, Map nested in an unsupported way, or a type that ends up neither ParameterizedType-handled nor a Class after raw-type resolution.","commonSituations":"Using jackson-jr module with methods typed to interfaces (e.g. List<T> declared as List but element not a Class), returning JAXBElement or custom generic wrappers, switching from the full jackson module (which handles more types) to jackson-jr.","solutions":["Change the Feign method return type to a concrete bean class that jackson-jr can map.","If you need rich type support, switch to the feign-jackson (full Jackson) decoder.","Register a custom decoder for the offending type via Feign.builder().decoder(new Decoder() {...}).","For generic wrappers, declare them as ParameterizedTypes with Class arguments the decoder's existing handling supports."],"exampleFix":"// before\n@GET Result-interface getUsers(); // interface type -> DecodeException\n// after\n@GET UserList getUsers(); // concrete bean class\nclass UserList { public List<User> users; }","handlingStrategy":"type-guard","validationCode":"static boolean jacksonJrCanDecode(Type type) {\n  if (type instanceof ParameterizedType) type = ((ParameterizedType) type).getRawType();\n  return type instanceof Class;\n}","typeGuard":"static boolean isBeanClass(Type type) {\n  if (type instanceof ParameterizedType) type = ((ParameterizedType) type).getRawType();\n  return type instanceof Class && !((Class<?>) type).isInterface();\n}","tryCatchPattern":"try {\n  return feignClient.call();\n} catch (feign.codec.DecodeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot decode type\")) {\n    throw new IllegalArgumentException(\"Return type unsupported by jackson-jr; use a concrete bean class\", e);\n  }\n  throw e;\n}","preventionTips":["Declare concrete bean return types in Feign interfaces when using jackson-jr","Avoid interface or generic-variable return types","Use feign-jackson (full Jackson) when complex types are needed"],"tags":["jackson-jr","decoder","type-mismatch","deserialization"],"backgroundTag":"unsupported-decode-type","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"}