Protobuf Required Fields

The cluster debates the absence of required fields in Protocol Buffers (especially proto3), weighing backwards compatibility benefits against the need for truly mandatory fields and schema evolution challenges.

➡️ Stable 0.8x Open Source
1,151
Comments
18
Years Active
5
Top Authors
#1801
Topic ID

Activity Over Time

2009
3
2010
5
2011
5
2012
8
2013
14
2014
24
2015
30
2016
53
2017
44
2018
89
2019
109
2020
112
2021
84
2022
112
2023
132
2024
142
2025
177
2026
8

Keywords

LD e.g IMHO RPC UNIX V1 IMO V3 UTC google.com fields protobuf field optional required message version protocol rpc proto

Sample Comments

thayne Dec 2, 2025 View on HN

One limitation of protobuf 3 schemas, is they doen't allow required fields. That makes it easier to remove the field in a later version in a backwards compatible way, but sometimes fields really are required, and the message doesn't make any sense without them. Ideally, IMO, if the message is missing those fields, it would fail to parse successfully. But with protobuf, you instead get a default value, which could potentially cause subtle bugs.

lazy_nerd Mar 11, 2010 View on HN

Protocol Buffers are flexible because they support 'optional' fields. So we can change the structure of Protocol Buffer without breaking the system.

jonbronson Dec 24, 2019 View on HN

"The solution is as follows:Make all fields in a message required. This makes messages product types."Except it also breaks backwards compatibility, one of the most powerful and sought-after features of protobufs.

stubish Jan 19, 2019 View on HN

I can't follow that argument, as it seems to apply just as much to wanting to change the type of a field, the name of a field or just making changes in general. Maybe I deal with relational databases too much, but I really miss being able to declare fields required and provide default values, because now instead I have to document, trust others will read the documentation, and provide explicit error handling for when constraints that used to be validated client side or server side by protob

cyberax Jul 10, 2025 View on HN

With Protobuf this is a conscious decision to avoid back-compat issues. I'm not sure if I like it.

SadCordDrone May 29, 2024 View on HN

Didn't read article fully, but - since it's protocall buffer definitions, what if these fields are there for backward compatibility?

skybrian Nov 1, 2023 View on HN

Compare with the usual rules for protobuf evolution:All fields are optional. This is because fields have a lifecycle. Your code might be reading data generated by some other code written before the field was defined, or generated by some other code written after the field became obsolete.With protobufs, you can never reuse a field number. However, you can remove a field (keeping its number reserved), which effectively means ignoring it in new applications. It's neither read nor writte

xyzzyz Dec 24, 2019 View on HN

I agree. Preserving unknowns fortunately was recognized as mistake, and fixed in some more recent version, and presence can be worked around: it is still preserved for message types, so you only need to wrap your primitives into objects[1], Java style.[1] - https://developers.google.com/protocol-buffers/docs/referenc...

orf Feb 4, 2025 View on HN

Why is the lack of a schema indicator the biggest flaw of protobuf?

isbadawi Jun 5, 2014 View on HN

If you don't currently have protobuf definitions, you can just not use required fields in any new ones you write, like the quoted passage suggests.