-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different max extension value if message_set_wire_format = true #308
Comments
Note that if syntax = "proto2";
package foo;
message Bar {
option message_set_wire_format = true;
extensions 2147483640 to max;
} But this is not: syntax = "proto2";
package foo;
message Bar {
extensions 2147483640 to max;
} The second one produces:
|
This may get really ugly - I'm not sure how you update the logic in protoreflect/desc/protoparse/proto.y Line 693 in c1f7119
The max tag validation might have to be done outside of the .y logic, and func TestParseMaxExtensionValue(t *testing.T) {
accessor := FileContentsFromMap(map[string]string{
"test.proto": `
syntax = "proto2";
message Foo {
extensions 4 to max;
}
`,
})
p := Parser{
Accessor: accessor,
}
fds, err := p.ParseFiles("test.proto")
testutil.Ok(t, err)
extensionRangeEnd := fds[0].GetMessageTypes()[0].GetExtensionRanges()[0].End
testutil.Eq(t, int32(internal.MaxTag), extensionRangeEnd)
}
func TestParseMessageSetWireFormatMaxExtensionValue(t *testing.T) {
accessor := FileContentsFromMap(map[string]string{
"test.proto": `
syntax = "proto2";
message Foo {
option message_set_wire_format = true;
extensions 4 to max;
}
`,
})
p := Parser{
Accessor: accessor,
}
fds, err := p.ParseFiles("test.proto")
testutil.Ok(t, err)
extensionRangeEnd := fds[0].GetMessageTypes()[0].GetExtensionRanges()[0].End
testutil.Eq(t, int32(internal.MaxTagMessageSetWireFormat), extensionRangeEnd)
} |
I believe this is basically the same underlying issue as #275, which are both around undocumented details of "message set" wire format, particularly the fact that the allowed tag range is different with this encoding format. |
I think I have a fix ready. It's a large-ish change because I decided to tackle some hygiene issues while in there (like trying to add some helper methods to make some of the gnarly error-handling slightly less verbose; and breaking up the over-sized While in there, I just happened to find a few other problems (#312, #313, and #314) and am fixing those as well. This change will also fix #307 -- which involved non-trivial changes to the grammar ( |
Fixed in #316 |
Very obscure:
With
protoc
:With protoreflect:
If you turn
message_set_wire_format
off, theprotoc
generated max extension value goes back to 536870912.The text was updated successfully, but these errors were encountered: