apache/kafka · error · IllegalArgumentException

Partition was not included in the original request

Error message

Partition {partition} was not included in the original request

What it means

Thrown by DeleteConsumerGroupOffsetsResult.partitionResult() when the requested TopicPartition was not part of the set passed to the original Admin.deleteConsumerGroupOffsets call. It guards against querying a per-partition future for a partition the result object does not track.

Solutions

  1. Ensure partitionResult is only called with TopicPartitions that were in the original deleteConsumerGroupOffsets request.
  2. Iterate over the result's known partitions instead of an external list.
  3. Retain the original Set<TopicPartition> and check membership before calling partitionResult.

Example fix

// before
result.partitionResult(new TopicPartition("orders", 5)); // may not be in request

// after
if (requestedPartitions.contains(tp)) {
    result.partitionResult(tp);
}
Defensive patterns

Strategy: validation

Validate before calling

Set<TopicPartition> requested = ...; // from original call
if (!requested.contains(tp)) {
    throw new IllegalArgumentException(tp + " not in original request");
}
result.partitionResult(tp);

Type guard

boolean wasRequested(Set<TopicPartition> requested, TopicPartition tp) {
    return requested.contains(tp);
}

Prevention

When it happens

Trigger: Calling partitionResult(tp) on a DeleteConsumerGroupOffsetsResult where tp is not in the partitions set captured at construction time.

Common situations: Calling code constructs a different TopicPartition object (same topic/partition numbers but queried against the wrong result), or iterating over a hardcoded partition list that does not match what was requested.

Related errors


AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11). Data as JSON: /api/errors/1145e28d098fdc83. Report an issue: GitHub.

Appendix: 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 996fb4585a)