Skip to content

Commit

Permalink
Report compile issue of expr string only if strict flag is set (#49)
Browse files Browse the repository at this point in the history
* Report issues if strict flag is set
* Update compile error test
  • Loading branch information
adityav-verma authored Sep 10, 2021
1 parent 2ad8ac2 commit 87f0797
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions policy/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,9 @@ func (tc *templateCompiler) compileExprString(id int64,
ast, iss := env.ParseSource(relSrc)
if iss.Err() == nil {
// If the expression parses, then it's probably CEL.
// Report type-check issues if they are encountered.
// Report type-check issues if they are encountered and strict flag is true.
ast, iss = env.Check(ast)
if iss.Err() != nil {
if iss.Err() != nil && strict {
tc.reportIssues(iss)
return nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ERROR: ../../test/testdata/validator_with_custom_function/template.invalid_function.yaml:30:23: undeclared reference to 'invalidFunc' (in container '')
| - match: invalidFunc(rule.port) < 0
| ......................^
ERROR: ../../test/testdata/validator_with_custom_function/template.invalid_function.yaml:31:15: undeclared reference to 'invalidFunc' (in container '')
| message: "invalidFunc"
| ..............^
| ......................^

0 comments on commit 87f0797

Please sign in to comment.