apache/kafka · warning · IllegalArgumentException
Topic {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 caller asks for the per-topic result of a topic that was not included in the original Admin.deleteShareGroupOffsets request. The result object only tracks topics originally supplied; any other topic name is rejected with IllegalArgumentException at lookup time rather than propagated through the future.
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 c31c9215e1)
Solutions
- Pass the exact topic string that was present in the original deleteShareGroupOffsets request set.
- Iterate the original topic set to look up each result instead of constructing new keys.
- Re-issue Admin.deleteShareGroupOffsets with the full set of topics you intend to query.
- Normalize topic names (trim, consistent case) before building both the request and the lookup.
Example fix
// before
Set<String> req = Set.of("orders");
DeleteShareGroupOffsetsResult r =
admin.deleteShareGroupOffsets("share-grp", req, new DeleteShareGroupOffsetsOptions());
r.topicResult("ORDERS").get(); // not in set
// after - lookup only topics in the request set
for (String t : req) {
r.topicResult(t).get();
} Defensive patterns
Strategy: validation
Validate before calling
// Keep the Set<String> of topics passed to deleteShareGroupOffsets and only call
// topicResult(...) for members of that set.
Set<String> requestedTopics = Set.of("orders", "shipments");
DeleteShareGroupOffsetsResult result =
admin.deleteShareGroupOffsets(shareGroup, requestedTopics, options);
String topic = "orders";
if (requestedTopics.contains(topic)) {
result.topicResult(topic).get();
} else {
log.warn("Topic {} was not in the delete request; skipping", topic);
} Try / catch
// Exception is thrown synchronously by topicResult(...).
try {
result.topicResult(topic).get();
} catch (IllegalArgumentException e) {
// `topic` was not part of the original deleteShareGroupOffsets request.
log.warn("Skipping topic {}: {}", topic, e.getMessage());
} Prevention
- Reuse the Set<String> passed to Admin.deleteShareGroupOffsets as the canonical list when calling topicResult(...).
- Prefer result.all() when you do not need per-topic error attribution.
- Normalize topic names (trim, case) before both the request and the lookup so a typo does not cause a membership miss.
- Do not source topic names from a different channel than the request set; a divergence is the direct cause of this error.
When it happens
Trigger: Calling result.topicResult(topic) where topic is not contained in the Set<String> passed to Admin.deleteShareGroupOffsets(group, topics, options). Occurs when the lookup uses a different topic name than the request set, or the caller reuses a result object against a fresh topic list.
Common situations: Caller builds the request topic list from one data source and the lookup key from another; topic name casing/whitespace mismatch; refactored code that changed which topics were requested; share group workflow against a topic the application did not actually delete offsets for.
Related errors
- Partition {partition} was not included in the original reque
- 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/354b9fdae7b55b28.json.
Report an issue: GitHub.