apache/kafka · error · IllegalArgumentException

Topic was not included in the original request

Error message

Topic {topic} was not included in the original request

What it means

Thrown by DeleteShareGroupOffsetsResult.topicResult() when the requested topic String was not in the set passed to the original Admin.deleteShareGroupOffsets call. Mirrors the consumer-group equivalent but for share groups, guarding per-topic future lookup.

Solutions

  1. Only call topicResult with topic names that were in the original deleteShareGroupOffsets request.
  2. Keep a reference to the original topic set and validate membership first.
  3. Trim/normalize topic strings to avoid whitespace or encoding mismatches.

Example fix

// before
result.topicResult("orders "); // trailing space, not in request

// after
if (requestedTopics.contains(topic.trim())) {
    result.topicResult(topic.trim());
}
Defensive patterns

Strategy: validation

Validate before calling

Set<String> requested = ...; // from original deleteShareGroupOffsets call
if (!requested.contains(topic)) {
    throw new IllegalArgumentException(topic + " not in original request");
}
result.topicResult(topic);

Type guard

boolean wasRequested(Set<String> requested, String topic) {
    return requested.contains(topic);
}

Prevention

When it happens

Trigger: Calling topicResult(topic) where topic is not contained in the topics set captured during construction of DeleteShareGroupOffsetsResult.

Common situations: Querying a topic that was not part of the original delete request, or a string mismatch (e.g. trailing whitespace, case difference) between the request and the lookup.

Related errors


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

Appendix: source

Thrown at clients/src/main/java/org/apache/kafka/clients/admin/DeleteShareGroupOffsetsResult.java:68

                result.completeExceptionally(throwable);
            } else {
                for (String topic : topics) {
                    if (maybeCompleteExceptionally(topicResults, topic, result)) {
                        return;
                    }
                }
                result.complete(null);
            }
        });
        return result;
    }

    /**
     * Return a future which can be used to check the result for a given topic.
     */
    public KafkaFuture<Void> topicResult(final String topic) {
        if (!topics.contains(topic)) {
            throw new IllegalArgumentException("Topic " + topic + " was not included in the original request");
        }
        final KafkaFutureImpl<Void> result = new KafkaFutureImpl<>();

        this.future.whenComplete((topicResults, throwable) -> {
            if (throwable != null) {
                result.completeExceptionally(throwable);
            } else if (!maybeCompleteExceptionally(topicResults, topic, result)) {
                result.complete(null);
            }
        });
        return result;
    }

    private boolean maybeCompleteExceptionally(Map<String, ApiException> topicLevelErrors,
                                               String topic,
                                               KafkaFutureImpl<Void> result) {
        Throwable exception;
        if (!topicLevelErrors.containsKey(topic)) {

View on GitHub (pinned to 996fb4585a)