opyeb protobuflab

protobuflab · Lint

What the linter checks

The three severity levels and the field number, reserved and enum mistakes that appear most often.

The linter reads a schema and reports every point that breaks a rule of the language, with a severity. Tools differ in what they inspect, so a diagnostic code helps. This tool splits codes by area and rule, such as field.numberReservedBand.

Three severities

The most frequent errors

Diagnostic codeMeaningHow to fix
field.numberRangeThe number is 0 or above 536,870,911Choose one in 1-536,870,911
field.numberReservedBandThe number is in 19000-19999Move it outside the reserved band
field.duplicateNumberTwo fields share a number in one messageAssign a new number to one of them
field.numberReservedA reserved number is used againUse another number or remove the reserved entry
enum.noZeroA proto3 enum has no zero valueAdd *_UNSPECIFIED = 0; as the first value
field.requiredInProto3required appears in proto3Drop the label and validate in code

Deletions leave reserved behind

Leaving a deleted field's number free lets a later field take it and mix old data into a new field. reserved 5; and reserved "legacy_ref"; make the compiler refuse the reuse. This tool reports such a reuse as an error, and a deletion protected by reserved as a note in the breaking check.

Names and style

Messages, enums and services should be PascalCase, fields lower_snake_case and enum values UPPER_SNAKE_CASE. A style violation is a warning, so it does not stop a build, but it is the usual reason generated names differ between languages.

Type resolution

A non-scalar field type is looked up among the messages and enums of the same file, from the innermost scope outward, then by a unique suffix match. If nothing matches, field.unknownType is reported.

Zero errors does not mean the schema is safe. The linter checks grammar and rules; it does not judge what the data means or whether it contains personal information.

Questions

Should every warning be removed?

No. Style warnings can stay if the team agrees. A repeated warning is still a sign that the convention should be written down.

Is optional allowed in proto3?

Yes, as explicit presence since 3.15. Use it only where presence must be distinguishable; otherwise the tool reports a note.

Why is a duplicate enum number an error?

When two names share a number, deserialization cannot decide which name it is. If aliases are intended, declare allow_alias.

The field-errors preset contains number range, reserved band, duplicate, reserved reuse and missing enum zero at once.

Open the tool

Written against the Protobuf language guide (proto2 and proto3) and the Protobuf encoding documentation. Every schema, byte string and name here is synthetic.