← Back to Pull requests

fix(registries): write and read the Confluent Protobuf message indexes #549

Closed
unknown closed this pull request without merging on Dec 01, 2026 08:31 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 05:50 UTC
Author

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 single 0 byte. ConfluentSchemaRegistry doesn't write them when serializing and hands data.subarray(5) straight to protobufjs when deserializing. So every Protobuf message written by a Confluent client fails with illegal 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 varint Writer and Reader. AVRO and JSON Schema are unchanged.

Tests


  • New test writes and reads the Confluent message indexes of ProtocolBuffers payloads checks the exact bytes for indexes [0], [1] and [1, 0] (top level and nested, with an enum before them) and decodes them back. It mocks fetch, so it runs without Docker, and it fails on main.

  • Against Confluent's own Python serializer and deserializer (confluent-kafka 2.16.2 with its offline mock registry), 2,000 random messages failed in each direction on main, and none with this change.

  • test/registries/confluent-schema-registry.test.ts without Docker: 43 of 65 pass with the change, 42 of 64 on main. The other 22 fail the same way on both because they need the docker-compose stack (19 Creating topics failed, 3 ECONNREFUSED 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 --noEmit and 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

    Diff: 299 lines (+224 / -75) across 3 files Reviewer: ShogunPanda Review duration: 3040m
    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
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40% (MEDIUM) · Higher = larger blast radius
    40%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.3% · Safe to merge
    17.3%