Repository navigation
Conversation
The dynamic adapter threw for map fields because it asked for an adapter of the map type. Use the map's value type for the value adapter, as the key adapter already uses its key type. Enable the map round-trip test and compare map bytes with protobuf-java.
Map entries without a value threw in the schema adapter when the value was an enum. Give the map value adapter the enum's zero constant as identity, as generated adapters do.
The zero identity for enum map values replaced built-in adapters such as NullValue. Only give the identity to schema enum adapters, so NullValue still rejects nonzero values.
oldergod
marked this pull request as ready for review
November 5, 2026 13:26
Generated enum adapters use the constant with tag 0 as identity. The schema enum adapter now does the same, so map values no longer need a separate adapter.
oldergod
force-pushed
the
bquenaudon/schema-adapter-maps
branch
from
November 9, 2026 16:33
6a6f7fc to
25f0587
Compare
`google.protobuf.NullValue` decodes to null, so the map adapter rejected valid entries with "Map entry with null value". The map adapter now accepts a null value when the value adapter is `STRUCT_NULL`. This fixes generated Kotlin and Java code and `Schema.protoAdapter`.
oldergod
force-pushed
the
bquenaudon/schema-adapter-packed
branch
from
November 9, 2026 17:35
83eb52d to
27099c0
Compare
oldergod
force-pushed
the
bquenaudon/schema-adapter-maps
branch
from
November 9, 2026 17:35
aba79f3 to
675d6d1
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.
Schema.protoAdapterthrewUnsupportedOperationExceptionfor any message with a map field.The value adapter asked the factory for an adapter of the map type itself.
This change uses the map's value type, as the key adapter already uses the key type.
The model shape is a
Mapof keys to values under the field name, as the old ignoredmapTestexpected.Map entries without a value decode to the identity value, as in generated adapters.
The schema enum adapter now uses the constant with tag 0 as its identity, as generated enum adapters do.
So a missing enum value decodes to the zero constant.
Wire requires enum map values to define 0 as the first constant, so this constant always exists for maps.
google.protobuf.NullValuedecodes to null, so the runtime map adapter rejected validNullValuemap entries with "Map entry with null value".This failed in generated Kotlin and Java code too.
The map adapter now accepts a null value only when the value adapter is
ProtoAdapter.STRUCT_NULL.Tests compare map bytes with protobuf-java
DynamicMessagein proto2 and proto3, andmapTestis enabled again.StructTestround trips aNullValuemap entry through generated Kotlin and Java code andSchema.protoAdapter, and compares the bytes with protoc.This PR is stacked on #3749.
Release note:
Schema.protoAdapternow supports map fields.The
identityof a schema enum adapter is now the name of its constant with tag 0, or null if there is none.Generated code and
Schema.protoAdapternow decodemap<K, google.protobuf.NullValue>entries.