Skip to content

parser updates, and kmsg protocol bug fixes#1265

Merged
twmb merged 5 commits intomasterfrom
parser
Feb 23, 2026
Merged

parser updates, and kmsg protocol bug fixes#1265
twmb merged 5 commits intomasterfrom
parser

Conversation

@twmb
Copy link
Owner

@twmb twmb commented Feb 23, 2026

A test now exists for the parser to compare my DSL to Kafka json files. That found, unfortunately for me, a

TECHNICALLY the protocol changes in kmsg are BREAKING CHANGES.

That said, the current parsing is WRONG and using the protocols that are being fixed here just outright doesn't work.
I checked and none of this repo uses these protocol requests.
I'm going to push this as a patch since it's straight up a bug fix; existing code is unusable.

Any change in the generate directory will trigger a test in CI validating it against the Kafka protocol.

twmb and others added 5 commits February 22, 2026 17:54
Seven improvements to the code generator, all purely internal
refactors that produce identical generated output:

- Thread file/line context into all parse errors via scanner.dief()
- Replace right-to-left request modifier parsing with split-and-switch
- Replace notTopLevelRe regex with simple suffix check + modifier loop
- Extract parseSpecialField() for ThrottleMillis/TimeoutMillis detection
- Extract resolveType() from BuildFrom for type resolution
- Move tag/version validation from gen.go into a post-parse validateStructs() pass
- Add mustParseInt/mustParseUint helpers to reduce numeric Defaulter boilerplate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Validates structural equivalence between the DSL definitions and the
Kafka project's JSON message definitions: version ranges, field types,
tags, nullable properties, and field ordering at every protocol version.

Set KAFKA_DIR to the Kafka repo root to run; skips otherwise. Excludes
versions marked latestVersionUnstable in the JSON.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- AddRaftVoterRequest, UpdateRaftVoterRequest: Listeners.Port int16 → uint16
- AlterPartitionRequest: NewIsrWithEpochs.BrokerEpoch int32 → int64
- DescribeTopicPartitionsResponse: ErrorCode fields int32 → int16
- EndQuorumEpochRequest: PreferredSuccessors v0-v0 (was all versions)
- ShareFetchRequest: PartitionMaxBytes v0-v0 (was all versions)
- UpdateFeaturesResponse: Results v0-v1 (was all versions)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sparse-checks out apache/kafka for just the JSON message definitions
and runs the validation test. Triggers on changes to generate/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@twmb twmb merged commit ee41519 into master Feb 23, 2026
@twmb twmb deleted the parser branch February 23, 2026 02:15
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.

1 participant