One of the attractive features of protocol buffers is that it allows you extend the message definitions without breaking code that uses the older definition. In the case of an e
Yes, the best approach is to make the first value in the enum something like UNKNOWN = 0
. Then old programs reading a protobuf with an enum value they don't recognize will see it as UNKNOWN
and hopefully they can handle that reasonably, eg by skipping that element.
If you want to do this you'll also want to make the enum be optional
not required
.
required
, generally, means "I'd rather the program just abort than handle something it doesn't understand."
Note that it must be the first value declared in the proto source - just being the zero value doesn't make it the default.