-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
repeated custom options cannot be parsed #1142
Comments
Running up against this problem when trying to parse Here is an example of repeated options that can't be parsed:
In another file in that repository, these custom field options also cannot be parsed (though this may be a totally different issue):
|
@rclark Just found your post while working with the same set of proto files from Envoy. |
@nicolasnoble @alexander-fenster Is there any intention to fix this? |
@eyalpost We haven't looked at this one yet, so the below text is just some general thoughts. When we looked at similar issues before, the questions that we asked often were "how does Anyway, the current suggestion here in this issue (replace an option value with a list of values) can break the current users so cannot be released without a semver major release. I wonder if there is a compatible and non-ugly way of making it work without breaking any of the existing code :) |
@alexander-fenster how about leaving |
@hugebdu That might be a good idea since adding the new property won't break the existing users and those who need repeated custom options can just start using it. Feel free to send a PR and we'll be happy to review it! |
Another question before starting to implement. extend google.protobuf.FieldOptions {
repeated int32 flags = 50000;
}
message TestFieldOptionsInt {
string field1 = 2 [(flags) = 555, (flags) = 666];
string field2 = 3 [(flags) = 777];
} I would expect |
I personally would expect it to return |
I tend to agree, but the main problem is that currently the parser does not resolve the option definition so it has no knowledge whether the option is repeated or not. |
@eyalpost I think this is fine, and this is exactly the raw options as the name suggests, so the user can choose how they process the options. We'll take a look at the PR early next week! Thank you for handling this. |
There's a limitation with the current implementation with message based options. Would love to hear your feedback on this. message Rule {
string val = 1;
string val2 = 2;
}
extend google.protobuf.MessageOptions {
repeated Rule rule = 50000;
}
message TestOptions {
option (rule) = {val : "X"};
option (rule) = {val2: "Y", val: "Z"};
} The current implementation will produce these [
{"(rule).val": "X"},
{"(rule).val2": "Y"},
{"(rule).val": "Z"}
] Which means there's no way to reconstruct the original definition. [
{"(rule)": {"val": "X"}},
{"(rule)": {"val2": "Y", "val": "Z"}}
] but I need to give it some more work before it's ready for review |
@alexander-fenster Opened a new PR: #1256 which implements proper parsing of options |
@alexander-fenster note that this new PR still keeps the current |
protobuf.js version: 6.8.8
repeated custom options are not supported due to being mapped to object type in
ReflectionObject#options
Maybe should be an array?
The text was updated successfully, but these errors were encountered: