OpenFeign/feign · error · IllegalArgumentException

Not supported type

Error message

Not supported type ${type}

What it means

Jackson3IteratorDecoder only supports return types of the form Iterator<T>. If the declared method return type is not a ParameterizedType (e.g. a raw Iterator, or a non-generic type), decode cannot determine the element type and throws IllegalArgumentException('Not supported type ...').

Solutions

  1. Change the Feign method signature to return Iterator<ElementDto> with an explicit type parameter
  2. If the endpoint returns a list, use List<ElementDto> with the regular Jackson3Decoder instead
  3. Use IteratorDecoder (wrapped) if you need Iterator<X> inside another generic container - but the outer type must still be parameterized
  4. Check the Contract-resolved MethodMetadata.returnType to confirm generics survived (avoid bridge/raw types)

Example fix

// before
@Get("/items") Iterator getItems();
// after
@Get("/items") Iterator<ItemDto> getItems();
Defensive patterns

Strategy: type-guard

Validate before calling

Type t = method.getGenericReturnType();
if (!(t instanceof ParameterizedType)) {
  throw new IllegalStateException("Decoder requires a parameterized return type, got: " + t);
}

Type guard

static boolean isIteratorOf(Type t) {
  return t instanceof ParameterizedType
      && ((ParameterizedType) t).getRawType() == java.util.Iterator.class;
}

Try / catch

try {
  return iteratorDecoder.decode(response, type);
} catch (IllegalArgumentException e) {
  throw new IllegalStateException("Use Iterator<T> return types with Jackson3IteratorDecoder: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Declaring a Feign interface method returning raw java.util.Iterator (no generic parameter), or any non-parameterized type (String, List, POJO), and having Jackson3IteratorDecoder selected as the decoder.

Common situations: Copy-pasting a method signature and dropping the generic parameter; returning Iterator from a helper whose Type erases generics; wiring Jackson3IteratorDecoder for endpoints that actually return a single object or a List.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of OpenFeign/feign@e2a1e27560 (2026-09-10). Data as JSON: /api/errors/97cbe929ad90f9c0. Report an issue: GitHub.

Appendix: source

Thrown at jackson3/src/main/java/feign/jackson3/Jackson3IteratorDecoder.java:100

      // Read the first byte to see if we have any data
      reader.mark(1);
      if (reader.read() == -1) {
        return null; // Eagerly returning null avoids "No content to map due to end-of-input"
      }
      reader.reset();
      return new Jackson3Iterator<Object>(
          actualIteratorTypeArgument(type), mapper, response, reader);
    } catch (JacksonException e) {
      if (e.getCause() != null && e.getCause() instanceof IOException) {
        throw IOException.class.cast(e.getCause());
      }
      throw e;
    }
  }

  private static Type actualIteratorTypeArgument(Type type) {
    if (!(type instanceof ParameterizedType)) {
      throw new IllegalArgumentException("Not supported type " + type.toString());
    }
    ParameterizedType parameterizedType = (ParameterizedType) type;
    if (!Iterator.class.equals(parameterizedType.getRawType())) {
      throw new IllegalArgumentException(
          "Not an iterator type " + parameterizedType.getRawType().toString());
    }
    return ((ParameterizedType) type).getActualTypeArguments()[0];
  }

  public static Jackson3IteratorDecoder create() {
    return create(Collections.<JacksonModule>emptyList());
  }

  public static Jackson3IteratorDecoder create(Iterable<JacksonModule> modules) {
    return new Jackson3IteratorDecoder(
        JsonMapper.builder()
            .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
            // Disable FAIL_ON_TRAILING_TOKENS for iterator: we read a JSON array element by

View on GitHub (pinned to e2a1e27560)