quarkusio/quarkus · error · IllegalArgumentException
PartType annotation is only supported on fields and (setter/
Error message
PartType annotation is only supported on fields and (setter/getter) methods for multipart responses, found one on " + target
What it means
When generating multipart client code, Quarkus resolves the part name from @PartType/@RestForm/@FormParam annotated fields or setter/getter methods. If the annotated target is a method parameter, constructor, class, or another element kind, no valid part name can be extracted and an IllegalArgumentException is thrown at build time.
Source
Thrown at extensions/resteasy-reactive/rest-client-jaxrs/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java:590
constructor.returnValue(null);
}
return context.newInstance(dataClassName);
}
private String extractPartName(AnnotationTarget target, String fieldName) {
AnnotationInstance restForm;
AnnotationInstance formParam;
switch (target.kind()) {
case FIELD:
restForm = target.asField().annotation(REST_FORM_PARAM);
formParam = target.asField().annotation(FORM_PARAM);
break;
case METHOD:
restForm = target.asMethod().annotation(REST_FORM_PARAM);
formParam = target.asMethod().annotation(FORM_PARAM);
break;
default:
throw new IllegalArgumentException(
"PartType annotation is only supported on fields and (setter/getter) methods for multipart responses, found one on "
+ target);
}
return getAnnotationValueOrDefault(fieldName, restForm, formParam);
}
private String getAnnotationValueOrDefault(String fieldName, AnnotationInstance restForm, AnnotationInstance formParam) {
if (restForm != null) {
AnnotationValue restFormValue = restForm.value();
return restFormValue == null ? fieldName : restFormValue.asString();
} else if (formParam != null) {
return formParam.value().asString();
} else {
return fieldName;
}
}
private String createFieldFillerForSetter(AnnotationInstance partType, MethodInfo setter, String partName,View on GitHub (pinned to e1c734241f)
Solutions
- Move @PartType and @RestForm/@FormParam onto a field or a getter/setter method of the multipart response class
- Ensure the multipart DTO uses standard JavaBean fields or accessor methods
- Rebuild and verify the annotation targets with the client interface
Example fix
// before
public MultipartBody get(@PartType("text/plain") String id);
// after
class MultipartBody {
@PartType("text/plain")
@RestForm
public String file;
} Defensive patterns
Strategy: validation
Validate before calling
for (var f : dto.getClass().getDeclaredFields()) { if (f.isAnnotationPresent(PartType.class) == false && (f.isAnnotationPresent(RestForm.class) || f.isAnnotationPresent(FormParam.class))) throw new IllegalStateException("@PartType must sit on a field or accessor: " + f); } Type guard
boolean validPartTarget(java.lang.reflect.AnnotatedElement el) { return el instanceof java.lang.reflect.Field || el instanceof java.lang.reflect.Method; } Try / catch
try { client.post(body); } catch (IllegalArgumentException e) { if (e.getMessage().contains("PartType")) { log.error("Fix @PartType placement on multipart DTO"); } throw e; } Prevention
- Annotate only fields or getter/setter methods with @PartType
- Never put @PartType on client method parameters
- Keep multipart DTOs as simple JavaBeans
- Review annotation targets in the IDE before building
When it happens
Trigger: Placing @PartType (or having the multipart part-name extraction logic reach) an annotation target whose kind is not FIELD or METHOD inside an interface used as a REST client with multipart responses.
Common situations: Misplacing @PartType on a method parameter instead of a field/getter/setter of the multipart DTO; refactoring a field to a local variable; copy-pasting annotation placement between entity and client code.
Related errors
- Primitive types are not supported for multipart response map
- Unsupported field type for multipart response mapping: " + t
- Only a single argument can be annotated with '" + URL + "'.
- multipart responses can only be mapped to non-generic classe
- Unimplemented mode of use of 'io.quarkus.runtime.logging.Log
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/175a67757eb2f141.
Report an issue: GitHub.