Repository navigation
Conversation
`PROTOVALIDATE` compiles and type-checks CEL expressions, but a string
literal passed to `duration`, `timestamp`, or `matches` type-checks
regardless of its contents. An expression like `duration('1d')` (CEL
duration strings have no `d` unit) or `this.matches('^[a-z+$')` passes
lint, and only fails when protovalidate builds or evaluates the rule.
Enable cel-go's `ValidateDurationLiterals`, `ValidateTimestampLiterals`,
and `ValidateRegexLiterals` on the base CEL environment, so message,
field, and predefined rules all get the check. Each one only looks at
constant arguments and fails when the call fails for every input, so
these don't flag expressions that can succeed.
stefanvanburen
marked this pull request as ready for review
November 18, 2026 22:37
oliversun9
approved these changes
Nov 18, 2026
pkwarren
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noticed
buf linthappily accepts protovalidate rules likethis.matches('^[a-z+$')orthis < duration('1d')(CEL duration strings only supporth,m,s,ms,us, andns, nod), even though they can never succeed, while the equivalentstring.pattern = "^[a-z+$"gets flagged. This turns on cel-go's literal validators forduration,timestamp, andmatches, which only look at constant arguments, so they shouldn't flag anything that could actually pass.With this message:
buf linton v1.75.0 passes, and on this branch:A couple of caveats on the cel-go side. The message doesn't say what's wrong yet; cel-expr/cel-go#1674 adds the underlying error (e.g.
invalid matches argument: error parsing regexp: missing closing ]: ...). And the globalmatches(this, '...')form isn't checked until we're on a cel-go release with cel-expr/cel-go#1658, which isn't in v0.33.4. Both should come along for free with a futuremake upgrade.