TheThingsIndustries / protoc-gen-fieldmask

Generate field mask utilities from proto files
Apache License 2.0
10 stars 3 forks source link

Wrong oneof sub-fields #30

Closed adriansmares closed 4 years ago

adriansmares commented 4 years ago

Summary

Nested oneOf use the wrong sub-paths during SetFields.

Steps to Reproduce

  1. Create a message which contains two sub messages (i.e make messages instead of trivial types part of the one-of).
  2. Try to use SetFields with a valid field mask.
  3. The validation fails.

I've encountered while working on SetApplicationPubSub

https://github.com/TheThingsNetwork/lorawan-stack/blob/67cc2b31b079f9e9162f997306386a22b4bccf18/api/applicationserver_pubsub.proto#L72-L77

The generated code uses the wrong subfields while recursing on the oneof (subs instead of oneOfSubs). https://github.com/TheThingsNetwork/lorawan-stack/blob/67cc2b31b079f9e9162f997306386a22b4bccf18/pkg/ttnpb/applicationserver_pubsub.pb.setters.fm.go#L362-L385

What do you see now?

The subfields of the upper message are used (subs).

What do you want to see instead?

The subfields of the oneof message being used (oneOfSubs).

Environment

How do you propose to implement this?

Changing the code generation to respect the correct subs.

Can you do this yourself and submit a Pull Request?

Yes