Skip to content

reserved field inside group blocks fail parsing #2059

@jonathan-ioffe

Description

@jonathan-ioffe

Schemas with reserved inside a group fail parsing. For example;

message MyMessage {
  repeated group EntryResponse = 1 {
    optional string id = 2;
    reserved 3;
    optional string info = 4;
  }
}

Will fail with error:

Error: illegal token 'reserved' (test.proto, line 4)
    at illegal (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:96:16)
    at parseGroup_block (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:490:27)
    at ifBlock (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:311:17)
    at parseGroup (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:455:9)
    at parseField (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:381:13)
    at parseType_block (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:341:21)
    at ifBlock (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:311:17)
    at parseType (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:329:9)
    at parseCommon (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:282:17)
    at parse (/Users/ad/Desktop/protob/node_modules/protobufjs/src/parse.js:866:21)

The fix seems pretty simple, just to add an handle for it in parseGroup. Did it locally and was able to load properly the proto file.
Opened a PR so you could review: #2058
Thanks

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions