apache/kafka · warning · IllegalArgumentException
Partition {partition} was not included in the original reque
Error message
Partition {partition} was not included in the original request What it means
Thrown by DeleteConsumerGroupOffsetsResult.partitionResult when the caller asks for the per-partition result of a partition that was not in the original Admin.deleteConsumerGroupOffsets request set. The result object only tracks partitions the user originally passed; asking for any other TopicPartition is a programming error and is rejected immediately (IllegalArgumentException) rather than via the future.
Source
Thrown at clients/src/main/java/org/apache/kafka/clients/admin/DeleteConsumerGroupOffsetsResult.java:47
* The result of the {@link Admin#deleteConsumerGroupOffsets(String, Set)} call.
*/
@InterfaceAudience.Public
public class DeleteConsumerGroupOffsetsResult {
private final KafkaFuture<Map<TopicPartition, Errors>> future;
private final Set<TopicPartition> partitions;
DeleteConsumerGroupOffsetsResult(KafkaFuture<Map<TopicPartition, Errors>> future, Set<TopicPartition> partitions) {
this.future = future;
this.partitions = partitions;
}
/**
* Return a future which can be used to check the result for a given partition.
*/
public KafkaFuture<Void> partitionResult(final TopicPartition partition) {
if (!partitions.contains(partition)) {
throw new IllegalArgumentException("Partition " + partition + " was not included in the original request");
}
final KafkaFutureImpl<Void> result = new KafkaFutureImpl<>();
this.future.whenComplete((topicPartitions, throwable) -> {
if (throwable != null) {
result.completeExceptionally(throwable);
} else if (!maybeCompleteExceptionally(topicPartitions, partition, result)) {
result.complete(null);
}
});
return result;
}
/**
* Return a future which succeeds only if all the deletions succeed.
* If not, the first partition error shall be returned.
*/
public KafkaFuture<Void> all() {View on GitHub (pinned to c31c9215e1)
Solutions
- Pass the exact same TopicPartition object (or an equal topic+partition) that you included in the original deleteConsumerGroupOffsets call.
- Iterate over the original partition set instead of constructing new TopicPartition instances for lookup.
- Re-issue Admin.deleteConsumerGroupOffsets with the full set of partitions you intend to query.
- Verify topic name spelling, casing, and partition index before lookup.
Example fix
// before
Set<TopicPartition> req = Set.of(new TopicPartition("orders", 0));
DeleteConsumerGroupOffsetsResult r =
admin.deleteConsumerGroupOffsets("grp", req);
r.partitionResult(new TopicPartition("orders", 1)).get(); // not in set
// after - lookup only partitions present in the request set
for (TopicPartition tp : req) {
r.partitionResult(tp).get();
} Defensive patterns
Strategy: validation
Validate before calling
// Keep the exact Set<TopicPartition> handed to deleteConsumerGroupOffsets and
// only query partitionResult(...) for members of that set.
Set<TopicPartition> requested = Set.of(
new TopicPartition("orders", 0),
new TopicPartition("orders", 1));
DeleteConsumerGroupOffsetsResult result =
admin.deleteConsumerGroupOffsets(groupId, requested);
TopicPartition query = new TopicPartition("orders", 0);
if (requested.contains(query)) {
result.partitionResult(query).get();
} else {
log.warn("{} was not part of the delete request; skipping", query);
} Try / catch
// Note: the exception is thrown SYNCHRONOUSLY by partitionResult(...), not via the future.
try {
result.partitionResult(tp).get();
} catch (IllegalArgumentException e) {
// `tp` was not in the set passed to deleteConsumerGroupOffsets.
// Either reuse the original set, or drop this partition from processing.
log.warn("Skipping {}: {}", tp, e.getMessage());
} Prevention
- Store the Set<TopicPartition> passed to Admin.deleteConsumerGroupOffsets and iterate over it when collecting per-partition results.
- Do not reconstruct TopicPartition objects from external/untrusted input and feed them to partitionResult without a contains() check.
- When you only need an aggregate outcome, call result.all() instead of partitionResult(...) per partition.
- Treat the request set as the source of truth: derive every partitionResult query from it, not from a parallel data structure.
When it happens
Trigger: Calling result.partitionResult(tp) with a TopicPartition that is not equal (topic+partition) to one of the entries in the Set<TopicPartition> passed to Admin.deleteConsumerGroupOffsets. Typical when the caller builds the partition set and the lookup key from different sources, or mutates the set between request and result lookup.
Common situations: Stale references (request was built from one partition list, lookup uses another); copying example code and forgetting to substitute the actual request set; off-by-one in partition numbering; using a TopicPartition object whose topic string case differs from the request.
Related errors
- Topic {topic} was not included in the original request
- Topic partition {partition} was not included in the request
- TransactionalId `{transactionalId}` was not included in the
- TransactionalId `{transactionalId}` was not included in the
- Cannot specify a negative version level.
AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03).
Data as JSON: /data/errors/1145e28d098fdc83.json.
Report an issue: GitHub.