If you absolutely do need it, then in addition to "name" you can also add a field "hasName". If you feel fancy, you can even do that in a code generator.
A better example is Int32Value. By default, protobuf will serialize int32 to 0 if it's not present.
E.g.
- type.specified => “”
- type.unspecified => empty
The same technique can be used to disambiguate between 0 and empty.
Also the wrappers are known to most protobuf code generators, that can then use language features for better ergonomics. E.g. in Rust all wrappers to allow nullability of values will be turned in Option. Like the StringValue will turn into Option<String>.
As for the need, yes, it is needed. This carries intent, which is a good thing in customer facing APIs. An update endpoint will have all fields optional to distinguish between a field needing to be overridden or not, without the need to re-send the value when it does not need to be changed (à la PUT). Having additional boolean fields gets unwieldy quickly.
https://github.com/protocolbuffers/protobuf/blob/main/docs/f...