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

Custom options support #345

Open
upcFrost opened this issue Jan 6, 2023 · 3 comments
Open

Custom options support #345

upcFrost opened this issue Jan 6, 2023 · 3 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@upcFrost
Copy link

upcFrost commented Jan 6, 2023

Hi,

Does proto-plus support custom options? Especially FieldOptions, like this one

extend google.protobuf.FieldOptions {
  optional uint32 some_option = 50002;
}
message MyMessage {
  string id = 1 [(some_option) = 10];
}

In vanilla protobuf these options are available as proto_pb2.MyMessage.id.DESCRIPTOR.GetOptions().Extensions[proto_pb2.some_option], but I don't see them anywhere in proto-plus, neither in the proto.Field model description nor in the descriptor made with pb().

Best regards,
Petr

@upcFrost upcFrost added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Jan 6, 2023
@upcFrost
Copy link
Author

Case: I want to log requests and responses. Logging tokens and passwords is not exactly good. Keeping a huge dict what to log and what to skip is prone to errors. The best solution, imo, is to create an option like do_not_log and set it on the field. Then I can add custom logic on the logger to take field options into account. With this just by looking at the proto file I can tell which data is sensitive and should not be logged.

Another case: I want to add value checks on the field. For example, to have min and max values for integers. Adding it per-method is, again, prone to errors, and it's hard to tell why did the service reject the request w/o looking at the code. Having all those rules inside a proto file will make it much easier assess which conditions are set for each value

@upcFrost
Copy link
Author

anyone?

@tmc
Copy link

tmc commented Sep 5, 2023

Agreed that this is an important capability to support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants