Skip to content

enum-no-allow-alias

Protobufsuspiciousno fixdefault: offprotobuf/buf-standard

Reports option allow_alias = true; in an enum.

Aliases give two names to one number. A value read from the wire becomes one of the names, which one depends on the generator, so the name in the code is not stable, and JSON output shows one of them.

To fix, give each value its own number, and remove the option.

Reported
...
}
enum Aliased {
option allow_alias = true;
ALIASED_UNSPECIFIED = 0;
...
}
protobuf:
lint:
rules:
enum-no-allow-alias: warn # off (default), warn, error

Enabled by the presets: protobuf/buf-standard.

Suppress one line with sudsy-disable-next-line enum-no-allow-alias 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 ENUM_NO_ALLOW_ALIAS full