Skip to content

binding-kafka: add AlterConsumerGroupOffsets (API key 53) support #1702

@jfallows

Description

@jfallows

Summary

Add ALTER_CONSUMER_GROUP_OFFSETS (API key 53) to the KafkaApi enum and
KafkaRequestBeginEx / KafkaResponseBeginEx unions. Required by the
mcp_kafka reset_offsets tool.

This API (introduced in Kafka 2.7) allows an admin client to reset committed
offsets for a consumer group. The group must be inactive (no running members)
at the time of the call — the Kafka broker returns NON_EMPTY_GROUP (error
code 68) if members are still active.

Required changes to kafka.idl

Add to KafkaApi enum:

ALTER_CONSUMER_GROUP_OFFSETS (53)

Add new request and response structs:

struct KafkaAlterGroupTopicPartition
{
    int32 partitionId;
    int64 offset;
    int32 leaderEpoch = -1;
    string16 metadata = null;
}

struct KafkaAlterGroupTopic
{
    string16 name;
    KafkaAlterGroupTopicPartition[] partitions;
}

struct KafkaAlterConsumerGroupOffsetsRequestBeginEx
{
    string16 groupId;
    KafkaAlterGroupTopic[] topics;
}

struct KafkaAlterGroupPartitionResult
{
    int32 partitionId;
    int16 error;
}

struct KafkaAlterGroupTopicResult
{
    string16 name;
    KafkaAlterGroupPartitionResult[] partitions;
}

struct KafkaAlterConsumerGroupOffsetsResponseBeginEx
{
    int32 throttle;
    KafkaAlterGroupTopicResult[] topics;
}

Add to KafkaRequestBeginEx union:

case 53: kafka::stream::KafkaAlterConsumerGroupOffsetsRequestBeginEx alterConsumerGroupOffsets;

Add to KafkaResponseBeginEx union:

case 53: kafka::stream::KafkaAlterConsumerGroupOffsetsResponseBeginEx alterConsumerGroupOffsets;

Notes

  • The offset field carries the resolved offset value. Resolution of
    "earliest" and "latest" symbolic offsets to concrete values is the
    responsibility of mcp_kafka — it calls KafkaFetchBeginEx (for latest)
    or uses offset 0 (for earliest) before constructing the
    AlterConsumerGroupOffsets request.
  • If NON_EMPTY_GROUP error is returned, mcp_kafka surfaces a clear error
    to the agent: "Consumer group must be inactive before resetting offsets."

Spec test coverage

Add scenarios to specs/binding-kafka.spec/ covering:

  • Successful offset reset for a single partition
  • Successful offset reset for all partitions on a topic (multiple entries)
  • Error: NON_EMPTY_GROUP (error code 68) — group has active members
  • Error: GROUP_AUTHORIZATION_FAILED

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions