apache/kafka · error · IllegalArgumentException
The method: memberResult is not applicable in 'removeAll'…
Error message
The method: memberResult is not applicable in 'removeAll' mode
What it means
Thrown by RemoveMembersFromConsumerGroupResult.memberResult(MemberToRemove) when removeAll() is true, i.e. the result was created from a 'remove all members' request. In removeAll mode there are no per-member futures because no specific members were supplied, so per-member lookup is meaningless. Use all() to wait for the bulk operation instead.
Solutions
- Branch on the request mode: if removeAll, call result.all(); otherwise call memberResult(member).
- Track whether you used the no-arg options and route the result handling accordingly.
- Read result.all() which works in both modes for a top-level success future.
Example fix
// before
KafkaFuture<Void> f = result.memberResult(member);
// after
KafkaFuture<Void> f = removeAllMode
? result.all()
: result.memberResult(member); Defensive patterns
Strategy: validation
Validate before calling
KafkaFuture<Void> f = removeAllMode
? result.all()
: result.memberResult(member); Type guard
static boolean isRemoveAll(RemoveMembersFromConsumerGroupOptions o) {
// removeAll mode is created by the no-arg constructor; track it at call site
return removeAllMode;
} Try / catch
KafkaFuture<Void> f;
try {
f = result.memberResult(member);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("removeAll")) {
f = result.all();
} else throw e;
} Prevention
- Carry an explicit removeAll boolean from the request site to the result-handling site.
- Prefer result.all() when you only need overall success.
- Read the AdminClient javadocs for the dual-mode result API before integrating.
When it happens
Trigger: Calling `result.memberResult(someMember)` on a RemoveMembersFromConsumerGroupResult returned by an admin.removeMembersFromConsumerGroup call made with the no-arg RemoveMembersFromConsumerGroupOptions (removeAll mode).
Common situations: Code reused across both targeted-removal and removeAll flows; UI that always calls memberResult regardless of how the request was issued; copy-paste from a targeted-removal example into a removeAll context.
Related errors
- Member was not included in the original request
- Invalid empty members has been provided
- Cannot create a new partition reassignment without any…
- Empty string is not allowed.
- Expected 0 <= minVersion <= maxVersion but received…
AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11).
Data as JSON: /api/errors/bcd6817707db52bc.
Report an issue: GitHub.
Appendix: source
Thrown at clients/src/main/java/org/apache/kafka/clients/admin/RemoveMembersFromConsumerGroupResult.java:85
} else {
for (MemberToRemove memberToRemove : memberInfos) {
if (maybeCompleteExceptionally(memberErrors, memberToRemove.toMemberIdentity(), result)) {
return;
}
}
}
result.complete(null);
}
});
return result;
}
/**
* Returns the selected member future.
*/
public KafkaFuture<Void> memberResult(MemberToRemove member) {
if (removeAll()) {
throw new IllegalArgumentException("The method: memberResult is not applicable in 'removeAll' mode");
}
if (!memberInfos.contains(member)) {
throw new IllegalArgumentException("Member " + member + " was not included in the original request");
}
final KafkaFutureImpl<Void> result = new KafkaFutureImpl<>();
this.future.whenComplete((memberErrors, throwable) -> {
if (throwable != null) {
result.completeExceptionally(throwable);
} else if (!maybeCompleteExceptionally(memberErrors, member.toMemberIdentity(), result)) {
result.complete(null);
}
});
return result;
}
private boolean maybeCompleteExceptionally(Map<MemberIdentity, Errors> memberErrors,
MemberIdentity member,View on GitHub (pinned to 996fb4585a)