-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Protobuf is not using correct packed option value when the syntax is set as proto2 #681
Comments
I wonder how your example is even working with two different root instances. protobuf.load(["proto/TestMessage.proto", "proto/TestMessageFlag.proto"], function(err, root) {
... |
I found the issue and submitted a pull request. Can you please review it? Using one root is exactly the same. |
For context: Only repeated enum fields, which also use varint encoding, are affected, because their type is not yet (reliably) known when parsing. Your PR fixes this by setting |
The fix only sets the flag when iProto3 is false which means we are using syntax="proto2" therefore if the packed option is undefined the default value should be false. It shouldn't matter if it is an enum or not as far as I know. |
See: #683 (comment) |
Shall I close this issue now? When is it going to be released to npm? |
It's on npm now as 6.6.4. |
Thanks a lot. |
protobuf.js version: 6.6.3
Even with the syntax = "proto2" library still packs the repeated enum fields.
TestMessage.proto
TestMessageFlag.proto
main node js file.
Run the code and it outputs: "<Buffer 0a 04 04 02 03 01>"
Now change the field to be unpacked with an option.
Now run the same code and it outputs: <Buffer 08 04 08 02 08 03 08 01>
Which is the correct value for unpacked repeated field.
syntax = "proto2" should by default use unpacked without the need for options.
The text was updated successfully, but these errors were encountered: