Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: show expr errors #13778

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion util/template/expression_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,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
Loading