OpenFeign/feign · error · IOException
is not a type supported by this decoder.
Error message
${type.getTypeName()} is not a type supported by this decoder. What it means
JsonEncoder/JsonDecoder's convert() method (used to coerce objects into org.json structures) throws an IOException naming the type when the object is neither a JSONObject, JSONArray, nor Map. It signals an incompatibility between the Java object being converted and the org.json model.
Solutions
- Convert the object to a Map before passing it to convert()
- Wrap collections manually into JSONArray/JSONObject first
- Use a full data-binding encoder/decoder (Jackson/Gson) for POJOs
Example fix
// before Object out = decoder.convert(myPojo, MyPojo.class); // IOException // after Map<String, Object> map = pojoToMap(myPojo); Object out = decoder.convert(map, Map.class);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(src instanceof Map) && !(src instanceof JSONObject) && !(src instanceof JSONArray)) {
throw new IllegalArgumentException("convert() needs Map or org.json type, got " + src.getClass());
} Type guard
boolean convertible(Object o){ return o instanceof Map || o instanceof JSONObject || o instanceof JSONArray; } Try / catch
try { return convert(obj, type); }
catch (IOException e) { throw new IllegalArgumentException("Unsupported source: " + obj.getClass(), e); } Prevention
- Only feed Maps and org.json types into JsonDecoder conversion helpers
- Serialize POJOs with a dedicated mapper first
When it happens
Trigger: Calling convert() with a plain POJO, primitive wrapper, List, or other non-Map/non-org.json object as the source type.
Common situations: Attempting to reuse JsonDecoder/JsonEncoder internals for arbitrary object conversion; feeding a Collection or custom bean where a Map or org.json type is required.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- is not a type supported by this decoder.
- ${e.getMessage()}
- ${jsonException.getMessage()}
- is not a type supported by this encoder.
- Status Code [ ] has already been declared to throw [ ] and…
AI-assisted analysis of OpenFeign/feign@e2a1e27560 (2026-09-10).
Data as JSON: /api/errors/759521421ad9fc5f.
Report an issue: GitHub.
Appendix: source
Thrown at json/src/main/java/feign/json/JsonDecoder.java:116
format("%s is not a type supported by this decoder.", type),
response.request());
}
@Override
public Object convert(Object object, Type type) throws IOException {
if (type instanceof Class) {
Class<?> cls = (Class<?>) type;
if (cls == JSONObject.class && object instanceof Map) {
return new JSONObject((Map<?, ?>) object);
}
if (cls == String.class) {
return object.toString();
}
}
if (object instanceof Map) {
return new JSONObject((Map<?, ?>) object);
}
throw new IOException(type.getTypeName() + " is not a type supported by this decoder.");
}
@Override
public boolean canDecode(Response response, Type type) {
return Util.isJsonContentType(response);
}
}
View on GitHub (pinned to e2a1e27560)