How a breaking change is judged
Protobuf compatibility has two layers: whether bytes already stored can be read with the new schema (wire compatibility), and whether existing code compiles against it (source compatibility). A breaking check looks mainly at the first.
The most dangerous changes
| Change | Wire effect | Verdict |
|---|---|---|
| Removed number, not reserved | Old data is ignored by the new schema | error |
| Renumbered field with the same name | The other side reads a different field | error |
| Type change, including int32 to int64 | The encoding differs and values break | error |
| repeated to singular or back | The wire reading differs | error |
| Field name change only | The wire is the same; JSON and code break | warning |
| Package change | Fully qualified type names change | error |
Similar types are still different
int32 and int64 are both varints, but their range and their ten-byte expansion for negatives differ. string and bytes are both length-delimited, but only one is UTF-8. So the tool treats a type change as an error even when the wire type is the same.
Delete with reserved
Leaving reserved 5; behind prevents the old number from being reused. The breaking check reports a removed number as a note when the new schema reserves it and as an error when it does not. Names can be protected the same way with reserved "legacy_ref";.
Enums and rpcs
- Removing an enum value is a warning: the wire still reads a number, but the old value loses its name.
- Changing an enum value's number is an error: the same name would point at a different number.
- Removing an rpc is a warning; changing its request or response type is an error.
Packages and message names
A package change alters every fully qualified type name. A message rename is inferred when a new message has the same field numbers, and reported as an error because Any, JSON mapping and generated type names break even though the wire is unchanged.
The check matches the two schemas by number. A field that exists only in the new schema is not an error by itself. Reusing an old number with a different type does hit the rules above.
Questions
Can I rename a field instead of deleting it?
The wire survives, but the JSON name and generated code change. Fix json_name, or treat the rename as a warning and agree on it with the team.
Can reserved be lifted later?
It is not recommended. If another field takes the number, old data quietly mixes in. Write a new field with a new number instead.
What about moving between proto2 and proto3?
The syntax change is a warning, but required, default and the enum zero rule change with it, so read the per-field diagnostics too.
The breaking-v1v2 preset shows a package change, type and label changes, a renumbering, and removed message, enum and rpc at once.
Written against the Protobuf language guide (proto2 and proto3) and the Protobuf encoding documentation. Every schema, byte string and name here is synthetic.