Repository navigation
Conversation
The dynamic adapter mapped packed fields to the repeated label. It wrote proto2 [packed = true] fields and proto3 repeated scalars unpacked. Map them to the packed label so encode and encodedSize match protoc. Decoding still accepts both forms.
The schema enum adapter sized values as signed 32-bit varints but wrote them as unsigned ones. Negative values took 10 bytes in the size and 5 bytes on the wire. Packed fields use that size as their length prefix, so the bytes were malformed. Size values as unsigned 32-bit varints, as generated enum adapters do.
oldergod
marked this pull request as ready for review
November 5, 2026 12:42
SchemaEncoder encodes option values with the schema adapter. This test checks the bytes of a packed custom option.
oldergod
force-pushed
the
bquenaudon/schema-adapter-packed
branch
from
November 9, 2026 17:35
83eb52d to
27099c0
Compare
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.
SchemaProtoAdapterFactorymappedEncodeMode.PACKEDtoWireField.Label.REPEATED.So
Schema.protoAdapterwrote proto2[packed = true]fields and proto3 repeated scalars unpacked.For example, proto3
repeated int32with 1, 2, 3 gave080108020803instead of0a03010203.This change maps
PACKEDtoWireField.Label.PACKED, so encode andencodedSizematch protoc.Decoding still accepts both forms, and
[packed = false]still writes unpacked.The schema enum adapter now sizes values as unsigned 32-bit varints, as it writes them and as generated enum adapters do.
Before, a negative enum value got a wrong packed length prefix.
SchemaEncoderuses this adapter for option values, so custom options with packed fields now encode packed, as protoc does.A new
SchemaEncoderTestcase checks these bytes.New tests compare the adapter output with protobuf-java
DynamicMessagebytes for every packable type in proto2 and proto3.Release note:
Schema.protoAdapternow writes packed fields packed.The file descriptor bytes that
SchemaEncoderand the gRPC reflection service inwire-reflectorreturn also change when a custom option has a packed field.