fix(registries): write and read the Confluent Protobuf message indexes #549
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 299 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.341
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #549"
general
weight: 0.35
ShogunPanda
The Confluent wire format for Protobuf puts the message indexes of the type right after the schema ID: a zigzag varint count and one zigzag varint per nesting level, with
[0]written as a single0byte.ConfluentSchemaRegistrydoesn't write them when serializing and handsdata.subarray(5)straight to protobufjs when deserializing. So every Protobuf message written by a Confluent client fails withillegal tag: field number 0, and Confluent deserializers can't read the messages this library writes.This writes the indexes after the schema ID, worked out from where the type sits in the parsed schema, and skips them before
Type.decode. It reuses the library's zigzag varintWriterandReader. AVRO and JSON Schema are unchanged.Tests
writes and reads the Confluent message indexes of ProtocolBuffers payloadschecks the exact bytes for indexes[0],[1]and[1, 0](top level and nested, with an enum before them) and decodes them back. It mocksfetch, so it runs without Docker, and it fails onmain.main, and none with this change.test/registries/confluent-schema-registry.test.tswithout Docker: 43 of 65 pass with the change, 42 of 64 onmain. The other 22 fail the same way on both because they need the docker-compose stack (19Creating topics failed, 3ECONNREFUSED 127.0.0.1:8004), so I couldn't run the integration tests, including the existing ProtocolBuffers one. Reading it, it checks the first 5 bytes and the library's own round trip, and both still hold.tsc -p tsconfig.base.json --noEmitand eslint on the changed files are clean.Compatibility
Protobuf messages already written by an unpatched version have no index bytes, so the patched version can't read them (Confluent clients can't read them today either). The API is marked experimental, but this may be worth a line in the release notes.
One limit: protobufjs doesn't model map-entry messages, so a type nested inside a message that also has
map<>fields can get a different nested index than protoc gives it. Top-level types, and nested types without maps, match exactly.I used Claude Code to find and check this.
Generated with Claude Code