Why you must not modify existing fields in future Protobuf versions
Protobuf doesn't prevent you from changing data types on your fields. But not all data types are compatible with each other. If you change the data type of just one of your fields to a data type that isn't compatible with it, you will make your whole interface incompatible with the existing clients.
In the following list, each bullet contains the data types that can be interchanged with each other:
int32
,uint32
,int64
,uint64
, andbool
int32
,uint32
,int64
,uint64
, andenum
valuessint32
andsint64
string
andbytes
, but only if thebytes
value uses UTF-8 encodingfixed32
andsfixed32
fixed64
andsfixed64
However, just because you can change the data type of a field, it doesn't mean that you should. For example, what would happen if you sent a negative value as int32
, but consumed it as a positive-only uint32
data type on the other side? The original value cannot...