{"record":{"id":"5afa3b32ff2340ed","repo":"apache/kafka","slug":"topic-partition-partition-was-not-included-in-th","errorCode":null,"errorMessage":"Topic partition {partition} was not included in the request","messagePattern":"Topic partition (.+?) was not included in the request","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/admin/DescribeProducersResult.java","lineNumber":42,"sourceCode":"\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.concurrent.ExecutionException;\n\n@InterfaceAudience.Public\npublic class DescribeProducersResult {\n\n    private final Map<TopicPartition, KafkaFuture<PartitionProducerState>> futures;\n\n    DescribeProducersResult(Map<TopicPartition, KafkaFuture<PartitionProducerState>> futures) {\n        this.futures = futures;\n    }\n\n    public KafkaFuture<PartitionProducerState> partitionResult(final TopicPartition partition) {\n        KafkaFuture<PartitionProducerState> future = futures.get(partition);\n        if (future == null) {\n            throw new IllegalArgumentException(\"Topic partition \" + partition +\n                \" was not included in the request\");\n        }\n        return future;\n    }\n\n    public KafkaFuture<Map<TopicPartition, PartitionProducerState>> all() {\n        return KafkaFuture.allOf(futures.values().toArray(new KafkaFuture<?>[0]))\n            .thenApply(nil -> {\n                Map<TopicPartition, PartitionProducerState> results = new HashMap<>(futures.size());\n                for (Map.Entry<TopicPartition, KafkaFuture<PartitionProducerState>> entry : futures.entrySet()) {\n                    try {\n                        results.put(entry.getKey(), entry.getValue().get());\n                    } catch (InterruptedException | ExecutionException e) {\n                        // This should be unreachable, because allOf ensured that all the futures completed successfully.\n                        throw new KafkaException(e);\n                    }\n                }\n                return results;","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/admin/DescribeProducersResult.java#L24-L60","documentation":"Thrown by DescribeProducersResult.partitionResult() when the given TopicPartition has no corresponding entry in the futures map captured at construction. This means the partition was not part of the original Admin.describeProducersShuffleStrategies / describeProducers request.","triggerScenarios":"Calling partitionResult(tp) where futures.get(tp) returns null — tp was not requested in the describeProducers call.","commonSituations":"Caller queries a partition that was not in the original request, or constructs a TopicPartition with a mismatched topic name or partition number.","solutions":["Only call partitionResult with TopicPartitions that were passed to the original describeProducers request.","Cache the original partition collection and check membership before lookup.","Use the all() future if you need results for every requested partition without per-partition lookup."],"exampleFix":"// before\nresult.partitionResult(new TopicPartition(topic, p));\n\n// after\nif (requestedPartitions.contains(tp)) {\n    result.partitionResult(tp);\n}","handlingStrategy":"validation","validationCode":"Set<TopicPartition> requested = ...;\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":["Cache the requested partition set and check membership before partitionResult.","Prefer the all() future for bulk retrieval to avoid per-partition lookups.","Ensure TopicPartition objects are reused, not reconstructed inconsistently."],"tags":["validation","admin","producer"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}