#1435·protobuf

protojson: marshal fieldmask with "*" path

Author: ericwennCreated Apr 18, 2022Updated Aug 10, 2026

We are following AIP recommendations for our APIs. For update methods (https://google.aip.dev/134#request-message) it is recommended to support a special *-fieldmask for modelling PUT (default is PATCH).

In go this would look something like:

go
&fieldmaskpb.FieldMask{
	Paths: []string{"*"},
},

However a message containing such *-fieldmasks are not possible to marshal with protojson, failing with:

proto: google.protobuf.FieldMask.paths contains invalid path: "*"

It is surprising that something that is fine to marshal with proto.Marshal can not be marshalled with protojson.Marshal. Is the validation in protojson overly strict wrt to this statement from the spec?

Fields name in each path are converted to/from lower-camel naming conventions. https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#json-encoding-of-field-masks