protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

do not allow to extend same field twice to prevent the error

Open ThePlenkov opened this issue 2 years ago • 4 comments

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 avatar Aug 02 '22 14:08 ThePlenkov

@ThePlenkov Would it be possible to add a unit test for this case? Thank you!

alexander-fenster avatar Aug 17 '22 18:08 alexander-fenster

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.

ThePlenkov avatar Aug 18 '22 10:08 ThePlenkov

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

ThePlenkov avatar Aug 18 '22 11:08 ThePlenkov

@alexander-fenster hi! Did you have a change to look at unit tests for this problem may be? Thank you!

ThePlenkov avatar Aug 24 '22 09:08 ThePlenkov

Hi! May I ask please what's the reason of this change not going through? Thanks!

ThePlenkov avatar Dec 10 '22 18:12 ThePlenkov

Thanks for the fix @ThePlenkov 🙇

jackkav avatar Dec 15 '22 11:12 jackkav

@alexander-fenster is there anything else blocking this PR review? It is responsible for fixing server reflection.

jackkav avatar Jan 19 '23 09:01 jackkav