quarkusio/quarkus · error · IllegalArgumentException
Attempt to pass at least two of form or regular entity as a
Error message
Attempt to pass at least two of form or regular entity as a request body in {restClientInterface}#{jandexMethod.name} What it means
A REST client method may carry at most one request body. Quarkus detected both a regular entity/body value and form parameters (or two body-ish sources) on the same method, which is ambiguous when building the HTTP request, so generation fails.
Source
Thrown at extensions/resteasy-reactive/rest-client-jaxrs/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java:2710
if (!exceptions.contains(Exception.class.getName()) && !exceptions.contains(Throwable.class.getName())) {
exceptions.add(RuntimeException.class.getName());
}
CatchBlockCreator catchBlock = tryBlock.addCatch(ProcessingException.class);
ResultHandle caughtException = catchBlock.getCaughtException();
ResultHandle cause = catchBlock.invokeVirtualMethod(
MethodDescriptor.ofMethod(Throwable.class, "getCause", Throwable.class),
caughtException);
for (String exception : exceptions) {
catchBlock.ifTrue(catchBlock.instanceOf(cause, exception))
.trueBranch().throwException(cause);
}
catchBlock.throwException(caughtException);
if (bodyValue != null || formParams != null) {
if (countNonNulls(bodyValue, formParams) > 1) {
throw new IllegalArgumentException("Attempt to pass at least two of form " +
"or regular entity as a request body in " +
restClientInterface.name().toString() + "#" + jandexMethod.name());
}
if (consumes != null && consumes.length > 0) {
if (consumes.length > 1) {
Set<String> uniqueConsumes = new TreeSet<>(Arrays.asList(consumes));
mediaTypeValue = uniqueConsumes.iterator().next();
if (uniqueConsumes.size() > 1) {
log.debugf("MicroProfile Rest Client `%s`'s method `%s` has multiple `@Consumes` values `%s`,"
+ " Content-Type will be set to `%s`."
+ " You can change Content-Type in a custom jakarta.ws.rs.ClientRequestFilter implementation.",
restClientInterface.name().toString(), jandexMethod.name(),
uniqueConsumes.stream().collect(Collectors.joining(", ")),
mediaTypeValue);
}
} else {View on GitHub (pinned to e1c734241f)
Solutions
- Remove one of the two bodies — either send the entity OR the form params, not both
- Move form fields into the entity DTO and send a single object
- Split into two endpoints/methods: one for the entity, one for the form-encoded request
Example fix
// before
@POST
@Path("submit")
void submit(MyEntity e, @FormParam("tag") String tag);
// after
@POST
@Path("submit")
void submit(SubmitRequest request); // request contains entity fields + tag Defensive patterns
Strategy: validation
Validate before calling
static void validateSingleBody(Class<?> client) {
for (var m : client.getDeclaredMethods()) {
int bodyish = 0;
for (var p : m.getParameters()) {
if (p.isAnnotationPresent(jakarta.ws.rs.FormParam.class)
|| p.isAnnotationPresent(org.jboss.resteasy.reactive.PartType.class)
|| p.isAnnotationPresent(org.jboss.resteasy.reactive.RestForm.class)) bodyish++;
}
for (var p : m.getParameters()) {
boolean annotated = p.getAnnotations().length > 0 && java.util.Arrays.stream(p.getAnnotations())
.anyMatch(a -> a.annotationType().getName().startsWith("jakarta.ws.rs."));
if (!annotated) bodyish++; // unannotated param = entity body
}
if (bodyish > 1) throw new IllegalStateException(
client.getName() + "#" + m.getName() + " mixes entity body and form params");
}
} Prevention
- One body per method: either an entity or form params, never both
- Fold form fields into a request DTO when both kinds of data are needed
- Review client interfaces in code review for mixed @FormParam + entity signatures
When it happens
Trigger: A client method with a @Body-style entity parameter plus @FormParam parameters, or a @MultipartForm combined with an entity argument, on a single interface method.
Common situations: Trying to POST a JSON body along with form fields in one call; mixing @MultipartForm with a payload argument after a refactor.
Related errors
- 'quarkus-narayana-lra' can only work if 'quarkus-rest-client
- Token exchange is required but OIDC client is configured to
- Not possible to define the scope %s for the REST client %s
- Unable to lookup configuration for REST Client ${restClientI
- RestClientProxy is closed
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/69f614daa74af121.
Report an issue: GitHub.