diff --git a/CHANGELOG.md b/CHANGELOG.md index 485006900a..50ad3c9491 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ - Add `textDocument/documentSymbol` support for `buf lsp serve`. - Fix LSP navigation for cached modules which could cause import paths to become unresolvable. - Update default value of `--timeout` flag to 0, which results in no timeout by default. +- Update `PROTOVALIDATE` lint rule to allow for custom rules that do not have `id` or `message` + fields. ## [v1.59.0] - 2025-10-20 diff --git a/private/bufpkg/bufcheck/bufcheckserver/internal/buflintvalidate/cel.go b/private/bufpkg/bufcheck/bufcheckserver/internal/buflintvalidate/cel.go index 7bf4ef8c9f..97a131ba84 100644 --- a/private/bufpkg/bufcheck/bufcheckserver/internal/buflintvalidate/cel.go +++ b/private/bufpkg/bufcheck/bufcheckserver/internal/buflintvalidate/cel.go @@ -145,8 +145,6 @@ func checkCEL( break } idToConstraintIndices[celID] = append(idToConstraintIndices[celID], i) - } else { - add(i, "%s has an empty %s.id. IDs should always be specified.", parentNameCapitalized, celName) } if len(strings.TrimSpace(celConstraint.GetExpression())) == 0 { add(i, "%s has an empty %s.expression. Expressions should always be specified.", parentNameCapitalized, celName) @@ -155,14 +153,6 @@ func checkCEL( ast, compileIssues := celEnv.Compile(celConstraint.GetExpression()) switch { case ast.OutputType().IsAssignableType(cel.BoolType): - if celConstraint.GetMessage() == "" { - add( - i, - "%s has an empty %s.message for an expression that evaluates to a boolean. If an expression evaluates to a boolean, a message should always be specified.", - parentNameCapitalized, - celName, - ) - } case ast.OutputType().IsAssignableType(cel.StringType): if celConstraint.GetMessage() != "" { add( diff --git a/private/bufpkg/bufcheck/lint_test.go b/private/bufpkg/bufcheck/lint_test.go index 4abf480c44..ed1443e97b 100644 --- a/private/bufpkg/bufcheck/lint_test.go +++ b/private/bufpkg/bufcheck/lint_test.go @@ -627,14 +627,12 @@ func TestRunProtovalidate(t *testing.T) { bufanalysistesting.NewFileAnnotation(t, "cel_field.proto", 116, 5, 120, 6, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_field.proto", 156, 5, 160, 6, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 22, 3, 26, 5, "PROTOVALIDATE"), - bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 28, 3, 32, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 34, 3, 38, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 40, 3, 44, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 46, 3, 50, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 52, 3, 56, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 58, 3, 62, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 58, 3, 62, 5, "PROTOVALIDATE"), - bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 64, 3, 68, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 70, 3, 74, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 76, 3, 80, 5, "PROTOVALIDATE"), bufanalysistesting.NewFileAnnotation(t, "cel_message.proto", 82, 5, 86, 7, "PROTOVALIDATE"), diff --git a/private/bufpkg/bufcheck/testdata/lint/protovalidate/proto/cel_message.proto b/private/bufpkg/bufcheck/testdata/lint/protovalidate/proto/cel_message.proto index 2470d1227c..7e3327ba5b 100644 --- a/private/bufpkg/bufcheck/testdata/lint/protovalidate/proto/cel_message.proto +++ b/private/bufpkg/bufcheck/testdata/lint/protovalidate/proto/cel_message.proto @@ -24,7 +24,7 @@ message MessageTest { message: "message", expression: "this == this" }; - // empty id + // empty id UPDATE this is now OK option (buf.validate.message).cel = { id: "", message: "message", @@ -60,7 +60,7 @@ message MessageTest { message: "uh", expression: "foo + bar", }; - // missing message with a bool expression + // missing message with a bool expression UPDATE: this is now OK option (buf.validate.message).cel = { id: "id5", message: "",