apache/kafka · error · IllegalArgumentException

Group ID not found

Error message

Group ID not found: {groupId}

What it means

An IllegalArgumentException thrown by ListShareGroupOffsetsResult.partitionsToOffsetInfo(groupId) when the supplied share-group groupId was not among the groups requested in the original listShareGroupOffsets call. The result only carries futures for the groups you asked about.

Solutions

  1. Only query for groupIds you passed into the listShareGroupOffsets request.
  2. Keep the requested collection in a variable and iterate it when reading per-group results.
  3. Trim/normalize groupId strings before both requesting and querying.

Example fix

// before
ListShareGroupOffsetsResult r = admin.listShareGroupOffsets(Set.of("sg1","sg2"));
r.partitionsToOffsetInfo("sg3"); // not requested

// after
r.partitionsToOffsetInfo("sg1");
Defensive patterns

Strategy: validation

Validate before calling

Set<String> requested = Set.copyOf(shareGroupIds);
ListShareGroupOffsetsResult r = admin.listShareGroupOffsets(requested);
for (String g : requested) r.partitionsToOffsetInfo(g);

Type guard

static boolean wasRequested(String groupId, Set<String> requested) {
    return requested.contains(groupId);
}

Prevention

When it happens

Trigger: Calling Admin.listShareGroupOffsets with a collection of groups, then calling result.partitionsToOffsetInfo(groupId) for a group not in that collection. Case/whitespace mismatch between the requested and queried group ids.

Common situations: Building the requested set from one source and querying from another; typos or trailing whitespace in group ids; reusing a stale id after the requested set changed.

Related errors


AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11). Data as JSON: /api/errors/04278c9f6eb9349d. Report an issue: GitHub.

Appendix: source

Thrown at clients/src/main/java/org/apache/kafka/clients/admin/ListShareGroupOffsetsResult.java:71

                    try {
                        offsets.put(groupId, future.get());
                    } catch (InterruptedException | ExecutionException e) {
                        // This should be unreachable, since the KafkaFuture#allOf already ensured
                        // that all the futures completed successfully.
                        throw new RuntimeException(e);
                    }
                });
                return offsets;
            });
    }

    /**
     * Return a future which yields a map of topic partitions to offsets for the specified group. If the group doesn't
     * have offset information for a specific partition, the corresponding value in the returned map will be null.
     */
    public KafkaFuture<Map<TopicPartition, SharePartitionOffsetInfo>> partitionsToOffsetInfo(String groupId) {
        if (!futures.containsKey(groupId)) {
            throw new IllegalArgumentException("Group ID not found: " + groupId);
        }
        return futures.get(groupId);
    }
}

View on GitHub (pinned to 996fb4585a)