protobuf.js
protobuf.js copied to clipboard
do not allow to extend same field twice to prevent the error
Fixing the issue #1783
In the case if we have a call like this:
Protobuf.Root.fromDescriptor(decodedDescriptorSet);
where decodedDescriptorSet constains files which have same field ( extension + original file ) like in my case validation.proto + google_protobuf.proto ( see the example from the referenced issue ).
@ThePlenkov Would it be possible to add a unit test for this case? Thank you!
To test the case you need to but a breakpoint here: https://github.com/protobufjs/protobuf.js/blob/62941d4321824a50d79b7487c1fc1b729002ad0e/src/root.js#L278
Then during comp_import_extend.js
test you may see that when we load proto and generate the descriptor - it works fine. But when we load one more root from the descriptor - the issue appears.
Probably the root of the problem is deeper - and the descriptor set should be generated differently - but I have no expertise to comment on that.
Actually I realized what happens - and is not even related to import. It's only about using fromDescriptor with extended fields. I've used a standard test.proto file for that
@alexander-fenster hi! Did you have a change to look at unit tests for this problem may be? Thank you!
Hi! May I ask please what's the reason of this change not going through? Thanks!
Thanks for the fix @ThePlenkov 🙇
@alexander-fenster is there anything else blocking this PR review? It is responsible for fixing server reflection.