Quick revision
The short answer
Because the Protocol Buffers wire format carries field numbers and wire types but no names, it is safe to add a field with a new number, to remove a field while reserving its number and name, and to rename a field (though JSON mappings and generated code change). It is breaking to change a field's number, reuse an old number for a different field, change to an incompatible type, or move fields into or out of a oneof carelessly. Reserved declarations stop accidental reuse, preserved unknown fields keep newer data alive through older services, and enums need a zero UNSPECIFIED value, added-only values and clients that handle unknown values.
What to remember
In this answer, we saw that protobuf compatibility follows from the wire format, which carries field numbers and wire types but no names. Adding fields, removing fields while reserving their numbers and names, and renaming are safe on the wire; changing numbers, reusing numbers, changing to incompatible types and careless oneof moves break readers, often silently. Reserved statements prevent accidental reuse, preserved unknown fields keep newer data through older services, enums need a zero UNSPECIFIED value and tolerant clients, and buf breaking can enforce all of this in CI.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Because the Protocol Buffers wire format carries field numbers and wire types but no names, it is safe to add a field with a new number, to remove a field while reserving its number and name, and to rename a field (though JSON mappings and generated code change). It is breaking to change a field's number, reuse an old number for a different field, change to an incompatible type, or move fields into or out of a oneof carelessly. Reserved declarations stop accidental reuse, preserved unknown fields keep newer data alive through older services, and enums need a zero UNSPECIFIED value, added-only values and clients that handle unknown values.
Why this question is asked
In a system with dozens of gRPC services, there is never a moment when everyone runs the same schema. A client built last year talks to a server deployed this morning, and a middle service may read a message and pass it on. Protocol Buffers were designed for exactly this, but only if we follow a few rules that come straight from the wire format. Interviewers ask this question because breaking those rules produces silent corruption rather than errors. In this answer, we will recap how a message is encoded, then go through safe and breaking changes with the reason for each, see how reserved and unknown fields protect us, look at enums, and finish with enforcing the rules automatically.
1A Quick Recap of the Wire Format
When a protobuf message is serialised, each field is written as a tag followed by a value. The tag combines the field number and a wire type, a small code that says how to read the value: varint for integers, bools and enums; 64-bit and 32-bit for fixed-size numbers such as double and float; length-delimited for strings, bytes and nested messages. The field name never appears on the wire.
A reader decodes each tag, looks up the field number in its own copy of the schema, and interprets the value with its own idea of that field's type. If it does not know the number, it skips the value using the wire type. So compatibility is entirely about numbers and wire types: two programs agree on data only if they agree on what each number means.
Notice that the bytes contain 1 and 2, never 'id' or 'name'. This single fact explains every rule that follows.
2Changes That Are Safe
Adding a field with a new number is safe in both directions. An old reader sees an unknown number and skips it; a new reader receiving an old message finds the field absent and uses its default value (zero, empty string, or 'not set' for fields with presence). The new code must handle that default sensibly.
Removing a field is safe as long as its number is never used again: old writers may still send it, and new readers skip it as unknown. That is why removal goes together with reserving the number and the name.
Renaming a field is safe on the wire, since names are not encoded. It is not free elsewhere: the generated Java getter changes from getEmail() to getContactEmail(), which breaks source code that calls it, and the JSON mapping (used by gRPC transcoding or JsonFormat) uses the field name, so JSON clients break. Treat renames as wire-safe but API-visible.
3Changes That Break, and Why
Changing a field's number breaks everything: old readers look for number 3 and find nothing, then find number 7 and skip it. Reusing an old number for a different field is worse, because it often does not fail at all: an old reader decodes the new field's bytes as the old field, and if the wire types match, it gets a plausible but wrong value.
Changing to an incompatible type breaks for the same reason. string and int64 have different wire types, so readers mis-parse or treat the value as unknown. Some changes are compatible on the wire, such as int32 to int64 (both varint), but values that do not fit in int32 are truncated by old readers, so even those need care. Moving an existing field into a oneof, or out of one, changes how readers decide which value is set, and if several fields of a oneof arrive, the last one wins, so old and new readers can disagree about the data.
| Change | Wire safe? | Why |
|---|---|---|
| Add field with new number | yes | old readers skip unknown numbers |
| Remove field, reserve number and name | yes | number can never mean something else |
| Rename field | yes on wire | names not encoded; Java getters and JSON change |
| Change field number | no | readers look for the old number |
| Reuse an old number for a new field | no, often silent | old readers decode it as the old field |
| string to int64, or similar | no | different wire type |
| Move field into or out of a oneof | risky | readers disagree about which field is set |
4Reserved Fields and Unknown Fields
When we delete a field, we add a reserved statement with its number and name. The compiler then refuses any later schema that uses them, so a colleague cannot pick 'the next free number' and accidentally reuse 4. Reserving the name also keeps JSON clients safe, since JSON uses names.
Unknown fields protect the reverse case. Suppose a new client sends Customer with phone = 8, and an older middle service reads the message, changes the name and writes it on. If the parser threw away field 8, the phone number would vanish in transit. Proto2 always kept unknown fields; proto3 dropped them at first, and since version 3.5 proto3 parsers keep them again and write them back out on serialisation. So a service that reads, modifies and rewrites a message preserves fields added by newer clients, as long as it reserialises the same message object rather than copying fields into a new one.
5Enums Need Extra Care
In proto3 the first enum value must be zero, and it should mean 'not set', for example STATUS_UNSPECIFIED = 0, because a missing enum field reads as zero. If zero meant ACTIVE, every message from an old client that never set the field would look active.
Only add enum values; never renumber or reuse them. And make clients handle values they do not know: proto3 enums are open, so a new server can send ARCHIVED = 4 to an old client. In Java, the generated getter then returns UNRECOGNIZED, and getStatusValue() returns 4. Code with a switch over the enum must have a default branch that does something safe, instead of assuming it has seen every value.
6Follow-up questions
How would a tool such as buf breaking enforce these rules in CI?
buf breaking compares the current .proto files with a reference, usually the last released version on the main branch or a published module in a schema registry, and reports changes that violate a chosen rule set, such as a deleted field without a reservation, a changed field number or type, or a field moved into a oneof. Running it as a required CI step on every pull request turns these rules from tribal knowledge into a check that blocks the merge. Teams pick a strictness level, for example the wire-compatibility rules for internal services and stricter source-compatibility rules for public APIs.
Is it safe to change a field from optional to repeated?
For scalar numeric fields the wire format is compatible, since a repeated field can be encoded as a sequence of single values and a non-repeated reader keeps the last one, but old readers silently drop all but one element. For strings and messages it is similar. It is rarely worth the risk; a new field is clearer.
7Conclusion
In this answer, we saw that protobuf compatibility follows from the wire format, which carries field numbers and wire types but no names. Adding fields, removing fields while reserving their numbers and names, and renaming are safe on the wire; changing numbers, reusing numbers, changing to incompatible types and careless oneof moves break readers, often silently. Reserved statements prevent accidental reuse, preserved unknown fields keep newer data through older services, enums need a zero UNSPECIFIED value and tolerant clients, and buf breaking can enforce all of this in CI.
Open with
The key fact is that the protobuf wire format carries field numbers and wire types, never names. So compatibility is about numbers. Adding a new field with a new number is safe: old readers skip the unknown number and new readers see a default when it is missing.
Then, if they want more
Removing a field is safe as long as I reserve its number and name, so nobody reuses them. Renaming is safe on the wire, though the generated Java getters and the JSON mapping change, so it can still break source or JSON clients.
The breaking changes are changing a field's number, reusing an old number for a different field, changing to an incompatible type like string to int64, and moving fields into or out of a oneof without care.
Reusing a number is the nastiest, because old readers decode the new data as the old field and often get plausible but wrong values with no error. reserved 4, 7 and reserved legacy_code make the compiler reject any reuse.
Unknown fields help in the other direction: since 3.5, proto3 parsers keep unknown fields, so a service that reads and rewrites a message does not drop fields added by newer clients. For enums, I keep a zero UNSPECIFIED value, only add values, and make clients handle UNRECOGNIZED in Java. And I would enforce it with buf breaking in CI.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Which changes to a .proto message are safe for old and new readers, which are breaking...": https://scrivio-interview-library.netlify.app/architecture/api-design-at-scale/4a35d04bec/