Repository navigation
Write and read proto2 groups in Google's wire format - #311
Open
quinnj-bot[bot] wants to merge 5 commits into
Open
quinnj-bot[bot] wants to merge 5 commits into
quinnj-bot[bot] wants to merge 5 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #311 +/- ##
==========================================
+ Coverage 94.18% 94.44% +0.25%
==========================================
Files 25 25
Lines 3115 3116 +1
==========================================
+ Hits 2934 2943 +9
+ Misses 181 173 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A group ends with an END_GROUP tag that carries the group's field number.
ProtoBuf.jl wrote a bare 0x04 (field 0) and only recognized that byte, so:
- Google's parsers could not read groups written by ProtoBuf.jl.
- Decoding a group written by Google failed with "Encountered END_GROUP
wiretype while skipping", including unknown groups that should be skipped.
- Encoding a message with an empty repeated group threw an AssertionError.
- A group inside a oneof was written as a length-delimited message.
- `_encoded_size` miscounted groups, so a length prefix written to a
non-IOBuffer stream could be wrong.
The encoder now writes the END_GROUP tag with the field number. The decoder
accepts any END_GROUP tag at the end of a group, so data written by earlier
versions still decodes. Generated `_encoded_size` methods pass Val{:group},
and generated oneof code encodes group members as groups.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code generated by ProtoBuf.jl before the decode signature change still decodes groups through GroupProtoDecoder; it now ends a group at an END_GROUP tag with any field number too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj-bot
Bot
force-pushed
the
claude/group-wire-format
branch
from
November 19, 2026 15:15
a5fcca5 to
a1290bf
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Why
proto2 groups (and editions' delimited encoding) end with an END_GROUP tag that carries the group's field number. ProtoBuf.jl wrote a bare
0x04(field 0) and only recognized that byte. As a result:Encountered END_GROUP wiretype while skipping. This also hits proto2 readers that skip an unknown group field, for example an older schema reading newer data.AssertionError: !(isempty(x)).oneofis written as a length-delimited message, which neither Google nor ProtoBuf.jl reads back as the group._encoded_sizemiscounts groups, so the length prefix of a message that contains a group can be wrong when encoding to a non-IOBufferstream.What changed
encode(e, i, x, Val{:group})writes the END_GROUP tag with field numberi, and an empty vector of groups writes nothing._encoded_size(x, i, Val{:group})counts two tags plus the content. Generated_encoded_sizemethods now passVal{:group}for group fields, and generated oneof code encodes and sizes group members as groups.Scope
_encoded_size) and for oneofs that contain groups. Code generated by earlier versions keeps working for decoding and for encoding to anIOBuffer; regenerating fixes the size of group fields.Blast Radius
Changes the bytes written for every group: the end tag now matches Google's. ProtoBuf.jl readers from before this change will fail to read those groups, so readers should upgrade before writers.
Verification
_encoded_sizefor groups, an empty repeated group, skipping an unknown group, decoding a group through the legacyGroupProtoDecoderpath used by code from older versions, and acomplex_message.protoround trip against bytes produced by Pythongoogle.protobuf(OmniMessagegroups, plus a newGroupOneofmessage).google.protobuf7.36.2 (upb), 420 seeded random proto2/proto3 messages with group schemas (optional, repeated, nested, field 100, inside a oneof, nested in another message, and unknown groups): decode failures drop from 134 on master to 71 on this branch, and every remaining failure involves a negative enum value (separate PR). The encode error on empty repeated groups is gone. With this batch's six fixes merged, all group cases match Python's values and bytes.Pkg.test()passes on Julia 1.10, 1.12, and 1.13 (1.13 with Fix CI: allow JET 0.12 and 0.13, drop the retired macOS-14 runner #309's JET compat).🤖 Generated with Claude Code