Skip to content

First enum value must be 0 in proto3 [protoprint] #581

@japersik

Description

@japersik

Hi,
I found another invalid case in protoprinter.
If you make a negative identifier in enum (yes, it is possible), then after compiling into a descriptor something like this:

enum MY_ENUM {
    MY_ENUM_UNSPECIFIED = 0;
    MY_ENUM_ONE = 1;
    
    FIELD_NEGATIVE_ID = -1;
}

after using protoprint, it turns into

enum MY_ENUM {
    FIELD_NEGATIVE_ID = -1;
    MY_ENUM_UNSPECIFIED = 0;
    MY_ENUM_ONE = 1;
}

The fields are sorted in ascending order. As a result, we get an invalid proto3 file because First enum value must be 0 in proto3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions