Skip to content

reserved field inside group blocks fail parsing #2059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jonathan-ioffe opened this issue Apr 11, 2025 · 0 comments
Open

reserved field inside group blocks fail parsing #2059

jonathan-ioffe opened this issue Apr 11, 2025 · 0 comments

Comments

@jonathan-ioffe
Copy link

jonathan-ioffe commented Apr 11, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant