Repository navigation
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
An editions DELIMITED field whose name is the lowercased name of its
type was written in text format under the type name whatever the scope
of the type, so `Payload payload = 1` with a top-level `Payload` came
out as `Payload { ... }`. C++ IsGroupLike and protobuf-go isGroupLike
also require the type to be nested in the field's own message, and for
any other field they write the field name and reject the type name, so
protoc and prototext could not read what buffa wrote.
text_field_name now takes the containing message's name and requires
the type's scope to match it. A type nested in the containing message
is in the same file, so this also covers their same-file check. The
generated parser stops accepting the type name for such a field, as
C++ and Go do. Proto2 groups are always nested in their message and
keep their type name.
v0ropaev
force-pushed
the
fix/text-group-like-scope
branch
from
October 28, 2026 12:24
ecadf63 to
a9dc821
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.
In text format, a field is written under its type's name instead of its own name when it is group-like. buffa decided that from the field's effective type and its name alone, so any DELIMITED field whose name is the lowercased type name counted as group-like. C++ (
IsGroupLikein descriptor.cc) and protobuf-go (isGroupLikein internal/filedesc) also require the type to be nested in the field's own message, in the same file. So in an editions file, a field named after a top-level type, a type nested in some other message, or an imported type was written under the type name, and protoc and prototext reject that name as an unknown field.buffa wrote
Payload {x: 1}for this message. protoc writespayload {x: 1}, andprotoc --encode=demo.Outerfails on buffa's output withMessage type "demo.Outer" has no field named "Payload". A buffa-to-buffa round trip hid the problem because the generated parser accepted both spellings.text_field_namenow gets the containing message's name and checks that the type is declared directly inside it. A type nested in the containing message is always in the same file, so this one check also covers the same-file rule. The writer and the parser both get their field names from this function, so the parser now accepts the type name only for a group-like field, as C++ does. Proto2 groups are always nested in their own message and keep their type name. The editions conformance messages also use nested types, so their output doesn't change.The new buffa-test fixture has an
Outermessage with DELIMITED fields of a top-level type, a type nested in another message, a type from another file, a repeated field and a oneof member, plus a type nested inOuteras the control. Its expected output matches what protoc 36.2 prints for the same message. There are also unit tests fortext_field_name.This touches the same
repeated_encode_stmtsignature in impl_text.rs as #802, so whichever goes in second will need a small rebase. I'm happy to do it.