Search code examples
protocol-buffersgrpc

What happened if you delete a field on protobuf?


example:

message Foo {
  ...
  string AccountToken = 3
  string BusinessToken = 4
  ...
}

since those 2 fields want to be deprecated by the project owner, can I safely remove those 2 fields just by deleting and regenerate the code then remove all reference?


Solution

  • Yes you can remove them. If the other side still sends these fields your newer code will just ignore them. But just like @LeiYang mentioned, use the deprecated syntax. Things will go wrong if a developer later uses index 3 or 4 for a different field. Especially if it is not of the same type, string in your case.