Protobuf compatibilityhard5-8 years

A teammate coming from an older protobuf version asks why `required` doesn't exist in proto3, and proposes simulating it with a comment convention (`// REQUIRED`) plus a check in every handler. Is that a reasonable substitute, and what was actually wrong with `required` in the first place?

required doesn't exist in proto3 on purpose, and the lesson states the specific reason directly: a required field can never be removed. Once a field is marked required and deployed, every future version of the schema is stuck carrying it forever, because dropping it would make old messages — which correctly have that field set — fail validation against a schema that no longer declares it required, and dropping the requirement itself doesn't help either, since there's no way to know if some already-deployed peer still enforces it strictly. Validating presence in the handler, instead of in the schema, sidesteps that permanently: the schema can evolve freely (add fields, remove fields, following the compatibility rules), and the validation logic — which is just application code — can change any time a release ships, with none of the wire-format permanence a schema-level required would lock in.

The lesson behind it →