Repository navigation
sbe: tell two schemas' template ids apart (#134) - #137
Merged
Merged
Conversation
This was referenced Nov 4, 2026
trendvidia
force-pushed
the
sbe-stale-122
branch
from
November 4, 2026 19:17
f75124d to
801d607
Compare
trendvidia
force-pushed
the
sbe-template-lookup-134
branch
from
November 4, 2026 19:17
3e8f6d4 to
c7e097e
Compare
A file or message carrying its SBE option at the pre-v1.12.0 number is reported as stale instead of missing or silently skipped, and the missing-schema-id error uses Go's words. The check moves to annotations.cc, shared with ProtoToXML.
A template id is unique only within a schema (draft -01 § SBE Annotations). The codec keyed messages by template id alone, so a second message with the same id replaced the first, NewView read one schema's bytes as another's message, and Unmarshal never compared the header's schema id. As protowire-go does (#253, #257): - Codec::New refuses two different messages with one (sbe.template_id) in one schema. The same message registered again is not a duplicate, and two schemas that share an id still bind. - by_id_ is keyed by (schema id, template id); NewView reads the schema id from header bytes 4-5 and refuses an unknown pair with "sbe: unknown template ID N in schema S". - Unmarshal and UnmarshalDescriptor refuse a schema id mismatch with "sbe: schema ID mismatch: got N, want M for template T". Tests ported from Go's encoding/sbe/template_id_test.go.
trendvidia
force-pushed
the
sbe-stale-122
branch
from
November 4, 2026 22:51
801d607 to
76f7a4e
Compare
trendvidia
force-pushed
the
sbe-template-lookup-134
branch
from
November 4, 2026 22:51
c7e097e to
bcedc19
Compare
Collaborator
Author
This was referenced Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #134.
Two schemas in one codec can now use the same template id without one hiding the other. Before, this port looked a message up by template id alone. A second message with the same id replaced the first,
NewViewread one schema's bytes as another schema's message, andUnmarshalnever compared the header's schema id. Ported from protowire-go #256, #258 and #270 (issues #253, #257).Codec::Newrefuses two different messages with one(sbe.template_id)in one schema:sbe: messages A and B share (sbe.template_id) = 7 in schema 1; it must be unique within a schema. A file passed twice still binds, and so do two schemas that share an id.NewViewlooks the template up by the header's schema id and template id. It refuses an unknown pair withsbe: unknown template ID 9 in schema 2; it used to sayunknown template id 9.UnmarshalandUnmarshalDescriptorrefusesbe: schema ID mismatch: got 1, want 2 for template 7. The version is not checked.This narrows what decodes: a caller that builds headers by hand must set the schema id. The CHANGELOG says so.
Stack and merge order: #123 → #124 → this PR → #132's PR → #133's PR. This PR's base is
sbe-stale-122(#124), since both editCodec::RegisterMessage.Evidence, at 3e8f6d4, on macOS:
ctest: 100% passed, 680 of 680, including 4 newSbeTemplateID.*tests ported from Go'stemplate_id_test.go.test/sbe_files.his a small compile helper for them.UnmarshalIntodisabled,SbeTemplateID.UnmarshalChecksSchemaIDfails.scripts/go_differential.shagainst protowire-go main 207fdfc and spec main: exit 1, from PXF only.Stream codecs differ(5schema ID mismatchcases, see the sbe: port the XML schema converters from protowire-go #123 comment). Those are gone.954 damaged streams decoded alike,201 big-number decodes ... alike,18 SBE schemas converted alike,362 documents.null is not allowed on required field(pxf: reject null on a (pxf.required) or @required field #131), formatter output for@dataset/@protodocuments (pxf: FormatDocument drops every directive, so a @dataset document formats to nothing #130), and a dataset cellunset, and the field is (pxf.required)(pxf: Marshal leaves out an unset (pxf.default) or (pxf.required) field, so it doesn't read back #129). Each has its own PR in progress.--dry-run --Werroron changed files: exit 0.src/sbe/codec.ccandsrc/sbe/unmarshal.cc: every remaining hit is on a line this PR does not touch (LoadU16,kDefaultMaxFrameSize). Those lines already pass CI's tidy-18.