Skip to content
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

Support l_bracket SpecialFieldName r_bracket in optionValues #2014

Open
visma-alexander-maslov opened this issue Aug 7, 2024 · 0 comments
Open

Comments

@visma-alexander-maslov
Copy link

protobuf.js version: 7.3.2

According to protobuf language specification option value in form of
MessageLiteralWithBraces = l_brace MessageTexFormat r_brace can have MessageLiteralFieldName represented as
l_bracket SpecialFieldName r_bracket (see Protobuf Text Format in spec).

Now https://github.com/protobufjs/protobuf.js/blob/master/src/parse.js#L638 checks only for the FieldName which equals to identifier but not for SpecialFieldName.

Valid proto (from Scalapb docs)

syntax = "proto3";

package mypkg;

import "scalapb/scalapb.proto";
import "scalapb/validate.proto";

option (scalapb.options) = {
  scope: PACKAGE
  [scalapb.validate.file] {
      validate_at_construction: true
      insert_validator_instance: true
      skip: false
  }
};
/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/pbjs.js:254
            throw err;
            ^

Error: illegal name '[' (option-values.proto, line 10)
    at illegal (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/node_modules/protobufjs/src/parse.js:96:16)
    at parseOptionValue (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/node_modules/protobufjs/src/parse.js:639:27)
    at parseOption (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/node_modules/protobufjs/src/parse.js:627:27)
    at parse (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/node_modules/protobufjs/src/parse.js:852:17)
    at process (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/node_modules/protobufjs/src/root.js:127:30)
    at fetch (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/node_modules/protobufjs/src/root.js:179:13)
    at Root.load (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/node_modules/protobufjs/src/root.js:207:13)
    at Root.loadSync (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/node_modules/protobufjs/src/root.js:248:17)
    at Object.main (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/pbjs.js:245:18)
    at Object.<anonymous> (/home/.nvm/versions/node/v20.11.0/lib/node_modules/protobufjs-cli/bin/pbjs:4:16)

Node.js v20.11.0

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