Skip to content

field-not-required

Protobufsuspiciousno fixdefault: offprotobuf/buf-standard

Reports a proto2 required field.

A required field can never be removed or made optional without breaking every reader and writer that was built before the change: an old reader rejects messages without it. Protobuf’s own advice is to avoid required.

To fix, make it optional and check for it in the code.

Reported
...
message Old {
required string name = 1;
}
protobuf:
lint:
rules:
field-not-required: warn # off (default), warn, error

Enabled by the presets: protobuf/buf-standard.

Suppress one line with sudsy-disable-next-line field-not-required in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
buf FIELD_NOT_REQUIRED full