Sobes.tech
Senior

What is protobuf? What happens when adding/removing a field?

sobes.tech AI

Answer from AI

Protocol Buffers (protobuf) is a compact, efficient, and cross-platform data serialization format developed by Google. It allows describing data structures in .proto files and automatically generating code for various programming languages.

When adding a new field to a protobuf message:

  • The new field must have a unique number (tag).
  • Old clients that do not know about the new field simply ignore it, ensuring backward compatibility.

When removing a field:

  • You cannot simply delete the field number, as this may lead to conflicts during deserialization.
  • Usually, the field is marked as "deprecated" and no longer used, but the field number is not reused.

Thus, protobuf supports schema evolution without breaking compatibility between different service versions.

What is protobuf? What happens when adding/removing a… - sobes.tech