Closed japersik closed 10 months ago
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
First enum value must be 0 in proto3
It reproduce when
protoprint.Printer{ SortElements: true }
Fixed in #582
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:
after using protoprint, it turns into
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