{"record":{"id":"0d9871f7c3ea176d","repo":"OpenFeign/feign","slug":"not-supported-type-type","errorCode":null,"errorMessage":"Not supported type ${type}","messagePattern":"Not supported type (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jackson/src/main/java/feign/jackson/JacksonIteratorDecoder.java","lineNumber":97,"sourceCode":"      // Read the first byte to see if we have any data\n      reader.mark(1);\n      if (reader.read() == -1) {\n        return null; // Eagerly returning null avoids \"No content to map due to end-of-input\"\n      }\n      reader.reset();\n      return new JacksonIterator<Object>(\n          actualIteratorTypeArgument(type), mapper, response, reader);\n    } catch (RuntimeJsonMappingException e) {\n      if (e.getCause() != null && e.getCause() instanceof IOException) {\n        throw IOException.class.cast(e.getCause());\n      }\n      throw e;\n    }\n  }\n\n  private static Type actualIteratorTypeArgument(Type type) {\n    if (!(type instanceof ParameterizedType)) {\n      throw new IllegalArgumentException(\"Not supported type \" + type.toString());\n    }\n    ParameterizedType parameterizedType = (ParameterizedType) type;\n    if (!Iterator.class.equals(parameterizedType.getRawType())) {\n      throw new IllegalArgumentException(\n          \"Not an iterator type \" + parameterizedType.getRawType().toString());\n    }\n    return ((ParameterizedType) type).getActualTypeArguments()[0];\n  }\n\n  public static JacksonIteratorDecoder create() {\n    return create(Collections.<Module>emptyList());\n  }\n\n  public static JacksonIteratorDecoder create(Iterable<Module> modules) {\n    return new JacksonIteratorDecoder(\n        new ObjectMapper()\n            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)\n            .registerModules(modules));","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/jackson/src/main/java/feign/jackson/JacksonIteratorDecoder.java#L79-L115","documentation":"JacksonIteratorDecoder decodes streaming Iterator<T> responses; actualIteratorTypeArgument requires the declared return type to be a ParameterizedType whose raw type is java.util.Iterator. Anything else throws IllegalArgumentException 'Not supported type'.","triggerScenarios":"Declaring a Feign method with JacksonIteratorDecoder whose return type is Iterator (raw, no generic parameter), List<T>, or any non-Iterator ParameterizedType — e.g. returning raw Iterator without <T>.","commonSituations":"Forgetting the generic parameter (raw Iterator), accidentally wiring the iterator decoder for methods returning List<T>, copy-pasting decoder config across methods with different return types.","solutions":["Declare the method return type as Iterator<T> with an explicit type argument.","Use the regular JacksonDecoder for non-Iterator return types like List<T>.","Wire JacksonIteratorDecoder only for the streaming methods that need it.","If T itself is generic, ensure it resolves to a concrete class."],"exampleFix":"// before\n@GET Iterator getUsers(); // raw Iterator -> Not supported type\n// after\n@GET Iterator<User> getUsers();","handlingStrategy":"type-guard","validationCode":"static boolean isIteratorType(Type type) {\n  return type instanceof ParameterizedType\n      && java.util.Iterator.class.equals(((ParameterizedType) type).getRawType());\n}\n// verify each Feign method's generic return type before wiring JacksonIteratorDecoder","typeGuard":"static boolean hasExplicitTypeArgument(java.lang.reflect.Method m) {\n  return isIteratorType(m.getGenericReturnType());\n}","tryCatchPattern":"try {\n  return streamingClient.streamUsers();\n} catch (feign.codec.DecodeException e) {\n  if (e.getCause() instanceof IllegalArgumentException && e.getCause().getMessage().startsWith(\"Not supported type\")) {\n    throw new IllegalStateException(\"Method must declare Iterator<T>, not raw/other types\", e);\n  }\n  throw e;\n}","preventionTips":["Always declare Iterator<T> with an explicit type argument","Wire the iterator decoder only for streaming methods","Review return types when changing decoder configuration"],"tags":["jackson","iterator","decoder","generics"],"backgroundTag":"type-mismatch","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"}