{"record":{"id":"1145e28d098fdc83","repo":"apache/kafka","slug":"partition-partition-was-not-included-in-the-orig","errorCode":null,"errorMessage":"Partition {partition} was not included in the original request","messagePattern":"Partition (.+?) was not included in the original request","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/admin/DeleteConsumerGroupOffsetsResult.java","lineNumber":47,"sourceCode":" * The result of the {@link Admin#deleteConsumerGroupOffsets(String, Set)} call.\n */\n@InterfaceAudience.Public\npublic class DeleteConsumerGroupOffsetsResult {\n    private final KafkaFuture<Map<TopicPartition, Errors>> future;\n    private final Set<TopicPartition> partitions;\n\n\n    DeleteConsumerGroupOffsetsResult(KafkaFuture<Map<TopicPartition, Errors>> future, Set<TopicPartition> partitions) {\n        this.future = future;\n        this.partitions = partitions;\n    }\n\n    /**\n     * Return a future which can be used to check the result for a given partition.\n     */\n    public KafkaFuture<Void> partitionResult(final TopicPartition partition) {\n        if (!partitions.contains(partition)) {\n            throw new IllegalArgumentException(\"Partition \" + partition + \" was not included in the original request\");\n        }\n        final KafkaFutureImpl<Void> result = new KafkaFutureImpl<>();\n\n        this.future.whenComplete((topicPartitions, throwable) -> {\n            if (throwable != null) {\n                result.completeExceptionally(throwable);\n            } else if (!maybeCompleteExceptionally(topicPartitions, partition, result)) {\n                result.complete(null);\n            }\n        });\n        return result;\n    }\n\n    /**\n     * Return a future which succeeds only if all the deletions succeed.\n     * If not, the first partition error shall be returned.\n     */\n    public KafkaFuture<Void> all() {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/admin/DeleteConsumerGroupOffsetsResult.java#L29-L65","documentation":"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.","triggerScenarios":"Calling partitionResult(tp) on a DeleteConsumerGroupOffsetsResult where tp is not in the partitions set captured at construction time.","commonSituations":"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.","solutions":["Ensure partitionResult is only called with TopicPartitions that were in the original deleteConsumerGroupOffsets request.","Iterate over the result's known partitions instead of an external list.","Retain the original Set<TopicPartition> and check membership before calling partitionResult."],"exampleFix":"// before\nresult.partitionResult(new TopicPartition(\"orders\", 5)); // may not be in request\n\n// after\nif (requestedPartitions.contains(tp)) {\n    result.partitionResult(tp);\n}","handlingStrategy":"validation","validationCode":"Set<TopicPartition> requested = ...; // from original call\nif (!requested.contains(tp)) {\n    throw new IllegalArgumentException(tp + \" not in original request\");\n}\nresult.partitionResult(tp);","typeGuard":"boolean wasRequested(Set<TopicPartition> requested, TopicPartition tp) {\n    return requested.contains(tp);\n}","tryCatchPattern":null,"preventionTips":["Retain the original partition set and check membership before partitionResult.","Iterate result-tracked partitions, not an externally-derived list.","Avoid reconstructing TopicPartition objects from raw strings/ints at lookup time."],"tags":["validation","admin","consumer-group"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}