Skip to content

Commit

Permalink
chore: show expr errors for #13759
Browse files Browse the repository at this point in the history
Signed-off-by: boiledfroginthewell <[email protected]>
  • Loading branch information
boiledfroginthewell committed Oct 17, 2024
1 parent 25bbb71 commit 330abc7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion util/template/expression_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ func expressionReplace(w io.Writer, expression string, env map[string]interface{
// This allowUnresolved check is not great
// it allows for errors that are obviously
// not failed reference checks to also pass
if err != nil {
fmt.Println("failed to compile:", err)
}
if err != nil && !allowUnresolved {
return 0, fmt.Errorf("failed to evaluate expression: %w", err)
}
result, err := expr.Run(program, env)
if (err != nil || result == nil) && allowUnresolved {
// <nil> result is also un-resolved, and any error can be unresolved
log.WithError(err).Debug("Result and error are unresolved")
log.WithError(err).Infof("Result and error are unresolved: result=%v", result)
fmt.Println("", err)
return w.Write([]byte(fmt.Sprintf("{{%s%s}}", kindExpression, expression)))
}
if err != nil {
Expand Down

0 comments on commit 330abc7

Please sign in to comment.