{"id":"354b9fdae7b55b28","repo":"apache/kafka","slug":"topic-topic-was-not-included-in-the-original-req","errorCode":null,"errorMessage":"Topic {topic} was not included in the original request","messagePattern":"Topic (.+?) was not included in the original request","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"clients/src/main/java/org/apache/kafka/clients/admin/DeleteShareGroupOffsetsResult.java","lineNumber":68,"sourceCode":"                result.completeExceptionally(throwable);\n            } else {\n                for (String topic : topics) {\n                    if (maybeCompleteExceptionally(topicResults, topic, result)) {\n                        return;\n                    }\n                }\n                result.complete(null);\n            }\n        });\n        return result;\n    }\n\n    /**\n     * Return a future which can be used to check the result for a given topic.\n     */\n    public KafkaFuture<Void> topicResult(final String topic) {\n        if (!topics.contains(topic)) {\n            throw new IllegalArgumentException(\"Topic \" + topic + \" was not included in the original request\");\n        }\n        final KafkaFutureImpl<Void> result = new KafkaFutureImpl<>();\n\n        this.future.whenComplete((topicResults, throwable) -> {\n            if (throwable != null) {\n                result.completeExceptionally(throwable);\n            } else if (!maybeCompleteExceptionally(topicResults, topic, result)) {\n                result.complete(null);\n            }\n        });\n        return result;\n    }\n\n    private boolean maybeCompleteExceptionally(Map<String, ApiException> topicLevelErrors,\n                                               String topic,\n                                               KafkaFutureImpl<Void> result) {\n        Throwable exception;\n        if (!topicLevelErrors.containsKey(topic)) {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/clients/admin/DeleteShareGroupOffsetsResult.java#L50-L86","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nSet<String> req = Set.of(\"orders\");\nDeleteShareGroupOffsetsResult r =\n    admin.deleteShareGroupOffsets(\"share-grp\", req, new DeleteShareGroupOffsetsOptions());\nr.topicResult(\"ORDERS\").get(); // not in set\n\n// after - lookup only topics in the request set\nfor (String t : req) {\n    r.topicResult(t).get();\n}","handlingStrategy":"validation","validationCode":"// Keep the Set<String> of topics passed to deleteShareGroupOffsets and only call\n// topicResult(...) for members of that set.\nSet<String> requestedTopics = Set.of(\"orders\", \"shipments\");\nDeleteShareGroupOffsetsResult result =\n    admin.deleteShareGroupOffsets(shareGroup, requestedTopics, options);\n\nString topic = \"orders\";\nif (requestedTopics.contains(topic)) {\n    result.topicResult(topic).get();\n} else {\n    log.warn(\"Topic {} was not in the delete request; skipping\", topic);\n}","typeGuard":null,"tryCatchPattern":"// Exception is thrown synchronously by topicResult(...).\ntry {\n    result.topicResult(topic).get();\n} catch (IllegalArgumentException e) {\n    // `topic` was not part of the original deleteShareGroupOffsets request.\n    log.warn(\"Skipping topic {}: {}\", topic, e.getMessage());\n}","preventionTips":["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."],"tags":["admin-client","share-groups","api-misuse","illegal-argument","request-set"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}