{"record":{"id":"f8ba32c52eecdda4","repo":"argoproj/argo-workflows","slug":"failed-to-evaluate-expression-w","errorCode":null,"errorMessage":"failed to evaluate expression: %w","messagePattern":"failed to evaluate expression: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/template/expression_template.go","lineNumber":246,"sourceCode":"\t\treturn 0, fmt.Errorf(\"failed to unmarshall JSON expression: %w\", err)\n\t}\n\n\tvarNameNotInEnv := anyVarNotInEnv(unmarshalledExpression, env)\n\tif varNameNotInEnv != nil && allowUnresolved {\n\t\t// this is to make sure expressions don't get resolved to nil or an empty string when certain variables\n\t\t// don't exist in the env during the \"global\" replacement.\n\t\t// See https://github.com/argoproj/argo-workflows/issues/5388, https://github.com/argoproj/argo-workflows/issues/15008,\n\t\t// https://github.com/argoproj/argo-workflows/issues/10393, https://github.com/expr-lang/expr/issues/330\n\t\tlog.WithField(\"variable\", *varNameNotInEnv).Debug(ctx, \"variable not in env but unresolved is allowed\")\n\t\treturn fmt.Fprintf(w, \"{{%s%s}}\", kindExpression, expression)\n\t}\n\n\tprogram, err := expr.Compile(unmarshalledExpression, expr.Env(env))\n\t// This allowUnresolved check is not great\n\t// it allows for errors that are obviously\n\t// not failed reference checks to also pass\n\tif err != nil && !allowUnresolved && !shouldAllowFailure {\n\t\treturn 0, fmt.Errorf(\"failed to evaluate expression: %w\", err)\n\t}\n\tresult, err := expr.Run(program, env)\n\tif (err != nil || result == nil) && (allowUnresolved || shouldAllowFailure) {\n\t\t//  <nil> result is also un-resolved, and any error can be unresolved\n\t\tlog.WithError(err).Debug(ctx, \"Result and error are unresolved\")\n\t\treturn fmt.Fprintf(w, \"{{%s%s}}\", kindExpression, expression)\n\t}\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to evaluate expression: %w\", err)\n\t}\n\tif result == nil {\n\t\treturn 0, fmt.Errorf(\"failed to evaluate expression %q\", expression)\n\t}\n\tresultMarshaled, err := json.Marshal(result)\n\tif (err != nil || resultMarshaled == nil) && allowUnresolved {\n\t\tlog.WithError(err).Debug(ctx, \"resultMarshaled is nil and unresolved is allowed \")\n\t\treturn fmt.Fprintf(w, \"{{%s%s}}\", kindExpression, expression)\n\t}","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/util/template/expression_template.go#L228-L264","documentation":"expr.Run (or compile) failed while evaluating an unmarshalled expression with the environment, and unresolved placeholders were not allowed. The wrapped error is from the expr engine — typically type errors, bad syntax, or referencing an unknown field.","triggerScenarios":"Thrown at util/template/expression_template.go:246 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the wrapped expr error to locate the failing sub-expression","Verify every variable in the expression exists in the environment","Test the expression with expr locally"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}