Skip to content

feat(binding-kafka): add OffsetDelete v0 wire codecs - #3181

Merged
jfallows merged 2 commits into
fix/3170-mqtt-kafka-discard-session-offsetsfrom
fix/3173-kafka-offset-delete-codec
Nov 13, 2026
Merged

jfallows merged 2 commits into
fix/3170-mqtt-kafka-discard-session-offsetsfrom
fix/3173-kafka-offset-delete-codec

Conversation

@jfallows

@jfallows jfallows commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds typed wire codecs for the Kafka OffsetDelete request (API key 47, version 0) to binding-kafka's public io.aklivity.zilla.runtime.binding.kafka.api package, which until now had no codec for it:

  • KafkaOffsetDeleteRequest: sizeof(Source, short), Source, and a Generator with the incremental topics / topic().name().partitions().partition() / build() builders and generate(Source).
  • KafkaOffsetDeleteResponse: topic/partition cursor exposing the top-level error code, the throttle time and per-partition error codes.
  • KafkaOffsetDeleteResponseV0FW: the v0 decoder.
  • protocol.idl: new offset_delete codec scope.

Structure and naming mirror KafkaFindCoordinatorRequest / KafkaFindCoordinatorResponseV3FW and, for the nested topic/partition arrays, KafkaListOffsetsRequest / KafkaListOffsetsResponseV6FW. No kafka.idl change, no new stream, no client factory. Only version 0 is supported, so sizeof throws for any other version. DeleteGroups (API key 42) is out of scope.

As with the sibling response codecs, interpreting the error codes and checking that the topics and partitions returned match those requested are the caller's job; the codec exposes the values it decodes unchanged.

This is the first cursor in the package with int32 array counts; the sibling cursors use varuint counts, which cannot go negative. A negative topic or partition count in the response makes next() throw IllegalStateException. This follows the existing truncation behaviour (an unchecked exception from the reader) and adds no new mechanism.

Base: this PR is stacked on fix/3170-mqtt-kafka-discard-session-offsets (head e82b3cf33d6e016773719373aba3c24b52d9bd18); it touches only binding-kafka's api package, its tests and protocol.idl, none of which the PRs below it change.

Fixes #3173

Protocol sources read

Every statement below was read from the files and page named here.

Message definitions (clients/src/main/resources/common/message/OffsetDeleteRequest.json and OffsetDeleteResponse.json in apache/kafka), downloaded with curl from raw.githubusercontent.com/apache/kafka at:

Ref Commit validVersions flexibleVersions headerVersions
tag 2.4.0 (first release with the API) 936016a236845ae953426bcb48c3bf73e70608ec "0" not present not present
tag 3.9.0 n/a (tag read via raw URL) "0" "none" not present
tag 4.0.0 985bc99521dd22bbf620591b8db8613c54f596b2 "0" "none" not present
trunk 2c620cd26873d916778aefcb8fc9b9b3d294d04b "0-1" "1+" request {"0": "1", "1+": "3"}, response {"0": "0", "1+": "1"}
  • Version implemented: 0 only. Every released tag read has "validVersions": "0". On trunk, version 1 exists and is marked unstable and flexible; the request file reads:
    // Version 1 enables flexible versions and uses the v3 request header (KIP-1313).
    "latestVersionUnstable": true,
    "validVersions": "0-1",
    "flexibleVersions": "1+",
    
    and the response file reads // Version 1 enables flexible versions., "validVersions": "0-1", "flexibleVersions": "1+". Version 1 is therefore not implemented.
  • Request header version at v0: 1. trunk states "headerVersions": {"0": "1", "1+": "3"} for the request. The released tags carry no headerVersions (flexibleVersions is none), so a non-flexible version uses the non-flexible header.
  • Response header version at v0: 0. trunk states "headerVersions": {"0": "0", "1+": "1"} for the response.
  • Request v0 fields: GroupId string; Topics array of { Name string; Partitions array of { PartitionIndex int32 } }.
  • Response v0 fields: ErrorCode int16 ("The top-level error code, or 0 if there was no error."); ThrottleTimeMs int32; Topics array of { Name string; Partitions array of { PartitionIndex int32; ErrorCode int16 ("The error code, or 0 if there was no error.") } }.

Protocol guide (https://kafka.apache.org/protocol, which redirects to https://kafka.apache.org/44/design/protocol/, downloaded and read): the "OffsetDelete API (Key: 47)" entry gives

OffsetDelete Request (Version: 0) => { group_id [topics] }
  group_id => STRING
  topics => { name [partitions] }
    name => STRING
    partitions => { partition_index }
      partition_index => INT32
Request header version: 1

OffsetDelete Response (Version: 0) => { error_code throttle_time_ms [topics] }
  error_code => INT16
  throttle_time_ms => INT32
  topics => { name [partitions] }
    name => STRING
    partitions => { partition_index error_code }
      partition_index => INT32
      error_code => INT16
Response header version: 0

and the same field descriptions as the JSON. The guide's primitive types define STRING as an INT16 length followed by UTF-8 bytes and ARRAY as an INT32 count followed by the items (the COMPACT_* forms and tagged fields apply to flexible versions only), which is the encoding this codec writes and reads.

Error codes the response carries: an INT16 top-level error_code for the group as a whole and an INT16 error_code per partition. The guide's OffsetDelete entry does not enumerate which codes occur; the codes are values of the guide's general error code table. Those relevant to this request there: UNKNOWN_TOPIC_OR_PARTITION 3, COORDINATOR_LOAD_IN_PROGRESS 14, COORDINATOR_NOT_AVAILABLE 15, NOT_COORDINATOR 16, INVALID_GROUP_ID 24, TOPIC_AUTHORIZATION_FAILED 29, GROUP_AUTHORIZATION_FAILED 30, UNSUPPORTED_VERSION 35, NON_EMPTY_GROUP 68, GROUP_ID_NOT_FOUND 69, GROUP_SUBSCRIBED_TO_TOPIC 86 ("Deleting offsets of a topic is forbidden while the consumer group is actively subscribed to it."). The codec exposes the numeric codes unchanged and does not interpret them.

Test evidence

  • The golden byte arrays in KafkaOffsetDeleteRequestTest and KafkaOffsetDeleteResponseV0FWTest were written by hand from the layout above, before the codec existed (the first commit contains only the tests); they are not copies of generator output. The test comments say they are laid out per the schema; they were not captured from a real Kafka encoder. As a cross-check, the three arrays (EXPECTED, BODY, GROUP_ERROR) were also compared against an independent encoding written separately from the guide layout with Python struct (>h string lengths, >i counts and indexes): all three matched byte for byte. The two malformed-response arrays (negative topic count, negative partition count) were written by hand the same way.
  • The history is two commits, test then implementation. At the first commit alone, test compilation fails with package ...KafkaOffsetDeleteRequest does not exist / cannot find symbol. With the implementation but without the negative-count guard, run on this base, 2 of the 4 KafkaOffsetDeleteResponseV0FWTest tests fail (shouldRejectNegativeTopicCount, shouldRejectNegativePartitionCount: expected:<IllegalStateException> but was:<IndexOutOfBoundsException>); with the guard they pass.
  • ./mvnw clean verify -pl runtime/binding-kafka -Dmaven.build.cache.skipCache=true on this branch (checkstyle and license checks on, upstream modules installed from the same checkout first): BUILD SUCCESS, 229 unit tests (218 on unmodified develop, plus the 11 new ones: 7 request, 4 response), 0 failures; 433 integration tests, 0 failures, 0 errors, 67 skipped.
  • Skipped tests, measured: an unmodified develop (555677939d623d2bcdb762181efd6adf92e2190a) build of runtime/binding-kafka (clean verify -Dmaven.build.cache.skipCache=true -Dskip.checks=true) reports the same 433 integration tests with 67 skipped and 218 unit tests with 0 skipped, so this change adds no skipped tests.
  • A full-reactor build with the cache skipped failed in the build module's notice check (unresolved manager / zpm-maven-plugin licenses), unrelated to this change; upstream modules were installed with -Dskip.checks=true instead.

Not delivered / follow-ups

  • OffsetDelete version 1 (flexible), once it is no longer marked unstable upstream.
  • DeleteGroups (API key 42).

🤖 Generated with Claude Code

https://claude.ai/code/session_01SiHVoUNXDUYPZYgFiM2Hx5

@jfallows
jfallows force-pushed the fix/3173-kafka-offset-delete-codec branch from 5ba89bf to aacd3e6 Compare November 13, 2026 02:03
@jfallows
jfallows changed the base branch from develop to fix/3170-mqtt-kafka-discard-session-offsets November 13, 2026 02:03
@jfallows
jfallows added this pull request to stack #3189 November 13, 2026 03:50
@jfallows
jfallows merged commit 2941e6b into develop Nov 13, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

binding-kafka: add OffsetDelete (v0) wire codecs to the public api package

2 participants