apache/kafka · error · IllegalArgumentException
The method: memberResult is not applicable in 'removeAll' mo
Error message
The method: memberResult is not applicable in 'removeAll' mode
What it means
Thrown by RemoveMembersFromConsumerGroupResult.memberResult(member) when the original request was in 'removeAll' mode (no-arg options). memberResult is only meaningful for per-member results of a targeted removal; in removeAll mode there is no specific member to look up, so the call is rejected.
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 c31c9215e1)
Solutions
- In removeAll mode, use all() to wait for overall completion instead of memberResult
- Branch on options.removeAll(): targeted -> memberResult(member); removeAll -> all()
- Refactor shared result handling to accept the mode and dispatch to the correct accessor
Example fix
// before
RemoveMembersFromConsumerGroupResult r =
admin.removeMembersFromConsumerGroup(groupId,
new RemoveMembersFromConsumerGroupOptions());
r.memberResult(member); // throws - removeAll mode
// after
KafkaFuture<Void> f = removeAll ? r.all() : r.memberResult(member);
f.get(); Defensive patterns
Strategy: validation
Validate before calling
RemoveMembersFromConsumerGroupResult result = admin.removeMembersFromConsumerGroup(groupId, options);
MemberToRemove member = ...;
if (options.removeAll()) {
// removeAll mode: use result.all(), NOT result.memberResult(member)
result.all().get();
} else {
// Only valid in non-removeAll mode and for a member originally requested.
result.memberResult(member).get();
} Type guard
static boolean canQueryMemberResult(RemoveMembersFromConsumerGroupOptions options, MemberToRemove member) {
return !options.removeAll() && options.members().contains(member);
} Try / catch
try {
result.memberResult(member).get();
} catch (IllegalArgumentException e) {
// Either removeAll mode was active (use result.all()) or member was not in the request.
// Fall back to the aggregate future.
result.all().get();
} Prevention
- Always branch on options.removeAll(): use all() in removeAll mode and memberResult() only otherwise.
- Only call memberResult() for MemberToRemove instances present in the options.members() set.
- Treat this exception as a logic bug in the caller, not a transient broker failure.
When it happens
Trigger: Calling result.memberResult(m) after the removal was issued with new RemoveMembersFromConsumerGroupOptions() (no members, i.e. removeAll). removeAll() returns true when memberInfos is empty, which is exactly the no-arg case.
Common situations: Reusing result-handling code between targeted and removeAll code paths; switching an operation from targeted removal to removeAll and forgetting to update the result accessors; generic code that always calls memberResult regardless of how the options were constructed.
Related errors
- Invalid empty members has been provided
- Offsets for consumer group '{groupId}' were not requested.
- Partition {partition} was not included in the original reque
- Topic {topic} was not included in the original request
- Topic partition {partition} was not included in the request
AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03).
Data as JSON: /data/errors/bcd6817707db52bc.json.
Report an issue: GitHub.