{"record":{"id":"97e1f9599c486884","repo":"argoproj/argo-workflows","slug":"failed-to-evaluate-expression-q","errorCode":null,"errorMessage":"failed to evaluate expression %q","messagePattern":"failed to evaluate expression %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/template/expression_template.go","lineNumber":258,"sourceCode":"\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}\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to marshal evaluated expression: %w\", err)\n\t}\n\tif resultMarshaled == nil {\n\t\treturn 0, fmt.Errorf(\"failed to marshal evaluated marshaled expression %q\", expression)\n\t}\n\tmarshaledLength := len(resultMarshaled)\n\n\t// Trim leading and trailing quotes. The value is being inserted into something that's already a string.\n\tif len(resultMarshaled) > 1 && resultMarshaled[0] == '\"' && resultMarshaled[marshaledLength-1] == '\"' {\n\t\treturn w.Write(resultMarshaled[1 : marshaledLength-1])\n\t}","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/util/template/expression_template.go#L240-L276","documentation":"expressionReplaceCore wraps the error from compiling/running the expr-lang expression after unmarshalling it, when failures are not permitted (allowUnresolved and shouldAllowFailure are both false). It fires during strict expression template resolution when the expression is syntactically invalid, references unknown env fields, or raises a runtime error, quoting the original expression.","triggerScenarios":"Thrown at util/template/expression_template.go:258 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the expression produce a concrete value (guard nils with sprig-like defaults or conditional logic)","Ensure referenced outputs actually exist before this template runs"],"exampleFix":null,"handlingStrategy":"validation","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"}