{"record":{"id":"175a67757eb2f141","repo":"quarkusio/quarkus","slug":"parttype-annotation-is-only-supported-on-fields-an","errorCode":null,"errorMessage":"PartType annotation is only supported on fields and (setter/getter) methods for multipart responses, found one on \" + target","messagePattern":"PartType annotation is only supported on fields and \\(setter/getter\\) methods for multipart responses, found one on \" \\+ target","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-client-jaxrs/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java","lineNumber":590,"sourceCode":"            constructor.returnValue(null);\n        }\n        return context.newInstance(dataClassName);\n    }\n\n    private String extractPartName(AnnotationTarget target, String fieldName) {\n        AnnotationInstance restForm;\n        AnnotationInstance formParam;\n        switch (target.kind()) {\n            case FIELD:\n                restForm = target.asField().annotation(REST_FORM_PARAM);\n                formParam = target.asField().annotation(FORM_PARAM);\n                break;\n            case METHOD:\n                restForm = target.asMethod().annotation(REST_FORM_PARAM);\n                formParam = target.asMethod().annotation(FORM_PARAM);\n                break;\n            default:\n                throw new IllegalArgumentException(\n                        \"PartType annotation is only supported on fields and (setter/getter) methods for multipart responses, found one on \"\n                                + target);\n        }\n        return getAnnotationValueOrDefault(fieldName, restForm, formParam);\n    }\n\n    private String getAnnotationValueOrDefault(String fieldName, AnnotationInstance restForm, AnnotationInstance formParam) {\n        if (restForm != null) {\n            AnnotationValue restFormValue = restForm.value();\n            return restFormValue == null ? fieldName : restFormValue.asString();\n        } else if (formParam != null) {\n            return formParam.value().asString();\n        } else {\n            return fieldName;\n        }\n    }\n\n    private String createFieldFillerForSetter(AnnotationInstance partType, MethodInfo setter, String partName,","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-client-jaxrs/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java#L572-L608","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\npublic MultipartBody get(@PartType(\"text/plain\") String id);\n// after\nclass MultipartBody {\n    @PartType(\"text/plain\")\n    @RestForm\n    public String file;\n}","handlingStrategy":"validation","validationCode":"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); }","typeGuard":"boolean validPartTarget(java.lang.reflect.AnnotatedElement el) { return el instanceof java.lang.reflect.Field || el instanceof java.lang.reflect.Method; }","tryCatchPattern":"try { client.post(body); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"PartType\")) { log.error(\"Fix @PartType placement on multipart DTO\"); } throw e; }","preventionTips":["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"],"tags":["quarkus","rest-client","multipart","annotation-misuse","build-time"],"backgroundTag":"invalid-annotation-target","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}