Skip to content

Protojson handling of field masks navigating into maps #1683

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

Open
patrickmeiring opened this issue Apr 8, 2025 · 1 comment
Open

Protojson handling of field masks navigating into maps #1683

patrickmeiring opened this issue Apr 8, 2025 · 1 comment

Comments

@patrickmeiring
Copy link

patrickmeiring commented Apr 8, 2025

https://google.aip.dev/161 proscribes that for a field of type map (e.g. map<string, string>),
we may allow field masks in requests that traverse into the map, e.g. "reviews, reviews.smith, reviews.John Smith". We use this in some places in our application.

However, we find that the FieldMask protojson implementation in go:

  1. Rejects keys into the map that have underscores (we must camel case the keys, even though in the map we upload, the keys are in snake case). While it is expected the deserialiser converts camelCase into snake_case for ordinary keys I am surprised to see it for map keys. As a corollary, there is no way to construct a field mask that matches a map key that is not in snake_case (e.g. "MyKey").
  2. The backtick notation (`) described in that API under "Map fields" does not work.

It seems the relevant code is here:
golang/protobuf/v2/encoding/protojson/well_known_types.go

I haven't been able to find a standards document for FieldMask in json proto to say authoritatively what it should/should not accept. Can you clarify? Are the AIPs recommending things the proto spec can't support? Is there a problem with the go protojson implementation?

Using google.golang.org/protobuf v1.36.5

@stapelberg
Copy link

(I had a brief look at the issue tracker and it seems like #1315 (comment) could be related.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants