{"record":{"id":"0881a3c79078d32b","repo":"apache/kafka","slug":"offsets-for-consumer-group-groupid-were-not-re","errorCode":null,"errorMessage":"Offsets for consumer group '{groupId}' were not requested.","messagePattern":"Offsets for consumer group '(.+?)' were not requested\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/admin/ListConsumerGroupOffsetsResult.java","lineNumber":66,"sourceCode":"     * Return a future which yields a map of topic partitions to OffsetAndMetadata objects.\n     * If the group does not have a committed offset for this partition, the corresponding value in the returned map will be null.\n     */\n    public KafkaFuture<Map<TopicPartition, OffsetAndMetadata>> partitionsToOffsetAndMetadata() {\n        if (futures.size() != 1) {\n            throw new IllegalStateException(\"Offsets from multiple consumer groups were requested. \" +\n                    \"Use partitionsToOffsetAndMetadata(groupId) instead to get future for a specific group.\");\n        }\n        return futures.values().iterator().next();\n    }\n\n    /**\n     * Return a future which yields a map of topic partitions to OffsetAndMetadata objects for\n     * the specified group. If the group doesn't have a committed offset for a specific\n     * partition, the corresponding value in the returned map will be null.\n     */\n    public KafkaFuture<Map<TopicPartition, OffsetAndMetadata>> partitionsToOffsetAndMetadata(String groupId) {\n        if (!futures.containsKey(groupId))\n            throw new IllegalArgumentException(\"Offsets for consumer group '\" + groupId + \"' were not requested.\");\n        return futures.get(groupId);\n    }\n\n    /**\n     * Return a future which yields all {@code Map<String, Map<TopicPartition, OffsetAndMetadata>} objects,\n     * if requests for all the groups succeed.\n     */\n    public KafkaFuture<Map<String, Map<TopicPartition, OffsetAndMetadata>>> all() {\n        return KafkaFuture.allOf(futures.values().toArray(new KafkaFuture<?>[0])).thenApply(\n            nil -> {\n                Map<String, Map<TopicPartition, OffsetAndMetadata>> listedConsumerGroupOffsets = new HashMap<>(futures.size());\n                futures.forEach((key, future) -> {\n                    try {\n                        listedConsumerGroupOffsets.put(key, future.get());\n                    } catch (InterruptedException | ExecutionException e) {\n                        // This should be unreachable, since the KafkaFuture#allOf already ensured\n                        // that all of the futures completed successfully.\n                        throw new RuntimeException(e);","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/admin/ListConsumerGroupOffsetsResult.java#L48-L84","documentation":"An IllegalArgumentException thrown by ListConsumerGroupOffsetsResult.partitionsToOffsetAndMetadata(groupId) when the supplied groupId was not among the groups requested in the original listConsumerGroupOffsets call. The result object only carries futures for the groups you asked about.","triggerScenarios":"Listing offsets for a set of groups, then calling partitionsToOffsetAndMetadata with a groupId that was not in that set. Case/whitespace mismatch between the requested id and the queried id.","commonSituations":"Building the requested set from one source and querying from another; typos in the group id; trailing whitespace from user input; reusing a stale groupId after the requested set changed.","solutions":["Only query for groupIds you passed into the listConsumerGroupOffsets request.","Keep the requested set in a variable and iterate it when reading per-group futures.","Trim/normalize groupId strings before both requesting and querying."],"exampleFix":"// before\nListConsumerGroupOffsetsResult r = admin.listConsumerGroupOffsets(Set.of(\"g1\",\"g2\"));\nr.partitionsToOffsetAndMetadata(\"g3\"); // not requested\n\n// after\nr.partitionsToOffsetAndMetadata(\"g1\");","handlingStrategy":"validation","validationCode":"Set<String> requested = Set.copyOf(groupIds);\nListConsumerGroupOffsetsResult r = admin.listConsumerGroupOffsets(requested);\nfor (String g : requested) r.partitionsToOffsetAndMetadata(g);","typeGuard":"static boolean wasRequested(String groupId, Set<String> requested) {\n    return requested.contains(groupId);\n}","tryCatchPattern":null,"preventionTips":["Iterate the exact set you passed into listConsumerGroupOffsets.","Trim/normalize group ids before requesting and querying."],"tags":["kafka-admin","consumer-groups","offsets","argument-validation","client-side"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}