quarkusio/quarkus · error · IllegalArgumentException
multipart responses can only be mapped to non-generic classe
Error message
multipart responses can only be mapped to non-generic classes, got " + result + " of type: " + result.kind()
What it means
For multipart responses, the generator must map the result type to a concrete non-generic class so it can index it and generate field fillers. If the resolved return type is a type variable, primitive, array-of-generic, or otherwise not a CLASS, it throws an IllegalArgumentException reporting the type and its kind.
Source
Thrown at extensions/resteasy-reactive/rest-client-jaxrs/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java:1461
}
}
}
}
}
private ClassInfo returnTypeAsClass(MethodInfo jandexMethod, IndexView index) {
Type result = jandexMethod.returnType();
if (result.kind() == PARAMETERIZED_TYPE) {
if (result.name().equals(COMPLETION_STAGE) || result.name().equals(UNI)) {
Type firstArgument = result.asParameterizedType().arguments().get(0);
if (firstArgument.kind() == CLASS) {
return index.getClassByName(firstArgument.asClassType().name());
}
}
} else if (result.kind() == CLASS) {
return index.getClassByName(result.asClassType().name());
}
throw new IllegalArgumentException("multipart responses can only be mapped to non-generic classes, " +
"got " + result + " of type: " + result.kind());
}
/**
* Tries to figure out the real type of type variable present in the given type, using the provided
* ownerIdentifierTypeLookupMap. Currently, types of kind PARAMETERIZED_TYPE and TYPE_VARIABLE are handled.
*
* @param type the type to resolve
* @param ownerIdentifierTypeLookupMap the lookup map type variable -> real type
* @param declaration The jandex declaration where the type was used.
* @return A type where all type variables are resolved, never null.
* @throws IllegalArgumentException if a type variable could not be resolved
*/
private Type resolveType(Type type,
Map<String, Type> ownerIdentifierTypeLookupMap, Declaration declaration) {
if (type.kind() == PARAMETERIZED_TYPE) {
ParameterizedType parameterizedReturnType = type.asParameterizedType();View on GitHub (pinned to e1c734241f)
Solutions
- Change the client method to return a concrete non-generic class for multipart responses
- If generics are needed, subclass with a concrete type argument (class StringWrapper extends Wrapper<String>) so resolution yields a CLASS
- Inspect the multipart method signature and remove type variables
Example fix
// before <T> T getMultipart(); // after MultipartBody getMultipart();
Defensive patterns
Strategy: validation
Validate before calling
static void assertNonGenericReturn(java.lang.reflect.Method m) { Type r = m.getGenericReturnType(); if (r instanceof TypeVariable || (r instanceof ParameterizedType pt && Arrays.stream(pt.getActualTypeArguments()).anyMatch(a -> a instanceof TypeVariable))) throw new IllegalStateException("Multipart return must be non-generic: " + r); } Type guard
boolean isConcreteReturn(java.lang.reflect.Method m) { return !(m.getGenericReturnType() instanceof TypeVariable); } Try / catch
try { client.get(); } catch (IllegalArgumentException e) { if (e.getMessage().contains("non-generic classes")) { log.error("Return a concrete class for multipart"); } throw e; } Prevention
- Return concrete classes from multipart client methods
- Subclass generic wrappers with concrete type arguments
- Avoid raw type variables in client interfaces
- Generate/test the client during CI to fail fast
When it happens
Trigger: Declaring a REST client method returning a generic type (e.g. T, Wrapper<T> where T is a method type variable) with multipart response handling, where resolveType cannot reduce it to a plain class.
Common situations: Generic client interfaces implemented for multiple types; using List<T> or a raw type variable as multipart return; inheritance-based generic DTOs.
Related errors
- PartType annotation is only supported on fields and (setter/
- Primitive types are not supported for multipart response map
- Unsupported field type for multipart response mapping: " + t
- Type variable %s of %s could not be resolved.
- Raw Map parameter types are not supported. Offending method
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4ad263f3b3b27fed.
Report an issue: GitHub.