You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would be happy if cel expression validation is supported.
Problem it solves or use case:
When I buf lint the following proto, the second mistake is caught by buf lint proto/xxx/greeting/v1/greeting.proto:35:79:field xxx.greeting.v1.SayHelloResponse.request_time: option (buf.validate.field).timestamp.lt_nowwww: field lt_nowwww of buf.validate.TimestampRules does not exist, but the first one (cel expression) is not. I'd like to know if the expression is valid or not.
messageSayHelloResponse {
stringmessage_id=1;
stringmessage=2 [(buf.validate.field).cel = {
id: "sayHelloResponse.message",
message: "message must start with 'Hello, ' and shorter than 1024",
expression: "(this.startsWith('Hello, ') && this.string.max_lennnn "
}];
google.protobuf.Timestamprequest_time=3 [(buf.validate.field).timestamp.lt_nowwwwwww = true];
}
Thank you so much for taking the time to bring this issue to our attention! I understand how validating CEL (Common Expression Language) expressions would be beneficial for ensuring the correctness and integrity of the configurations.
I'm excited to share that supporting CEL expression validation is actually on our roadmap. We understand the importance of catching these errors early on, and we plan to enhance our linter to include this feature. It will help streamline the development process by detecting and providing feedback on CEL syntax and semantic issues.
Your input is invaluable in helping us to shape the development of our project. We will keep the community posted on our progress, and we will definitely appreciate further feedback or suggestions as we work on the implementation.
Please feel free to add any more details or thoughts if you have them. Thanks again for your contribution!
Reacted by Toshinori Sugita, Gabriele Girelli and Matthew Benson
Hi @elliotmjackson, I'm really looking forward to using the feature!
Currently are there any ways to know if the expression is valid or not regardless of whether the check is static or dynamic?
And we would be glad to know the approximate delivery time on the roadmap because we are wondering when to start writing rules in PGV2. We have recently started using proto and made the decision not to start writing rules in PGV1 because of the articles about PGV2 being released and saving time in v1 -> v2 migration.
Fixed in bufbuild/buf#2505. buf lint now supports linting protovalidate rules, including CEL expression. It's enabled by the DEFAULT ruleset or can be added explicitly as PROTOVALIDATE
Activity
elliotmjackson commentedon Jun 13, 2023
Hi @toshi0607,
Thank you so much for taking the time to bring this issue to our attention! I understand how validating CEL (Common Expression Language) expressions would be beneficial for ensuring the correctness and integrity of the configurations.
I'm excited to share that supporting CEL expression validation is actually on our roadmap. We understand the importance of catching these errors early on, and we plan to enhance our linter to include this feature. It will help streamline the development process by detecting and providing feedback on CEL syntax and semantic issues.
Your input is invaluable in helping us to shape the development of our project. We will keep the community posted on our progress, and we will definitely appreciate further feedback or suggestions as we work on the implementation.
Please feel free to add any more details or thoughts if you have them. Thanks again for your contribution!
toshi0607 commentedon Jun 14, 2023
Hi @elliotmjackson, I'm really looking forward to using the feature!
Currently are there any ways to know if the expression is valid or not regardless of whether the check is static or dynamic?
And we would be glad to know the approximate delivery time on the roadmap because we are wondering when to start writing rules in PGV2. We have recently started using proto and made the decision not to start writing rules in PGV1 because of the articles about PGV2 being released and saving time in v1 -> v2 migration.
Keep rules value for evaluation (#28)
rodaine commentedon Jan 3, 2024
Fixed in bufbuild/buf#2505.
buf lintnow supports linting protovalidate rules, including CEL expression. It's enabled by theDEFAULTruleset or can be added explicitly asPROTOVALIDATEReplace protoc-gen-validate reference with protovalidate (bufbuild#28)