{"record":{"id":"6e6ffb6813bfa50a","repo":"argoproj/argo-workflows","slug":"failed-to-unmarshall-json-expression-w","errorCode":null,"errorMessage":"failed to unmarshall JSON expression: %w","messagePattern":"failed to unmarshall JSON expression: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/template/expression_template.go","lineNumber":228,"sourceCode":"\t\tif rv.Kind() == reflect.String {\n\t\t\tif IsPlaceholder(rv.String()) {\n\t\t\t\tshouldAllowFailure = true\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t})\n\n\tlog := logging.RequireLoggerFromContext(ctx)\n\t// The template is JSON-marshaled. This JSON-unmarshals the expression to undo any character escapes.\n\tvar unmarshalledExpression string\n\terr := json.Unmarshal(fmt.Appendf(nil, `\"%s\"`, expression), &unmarshalledExpression)\n\tif err != nil && allowUnresolved {\n\t\tlog.WithError(err).Debug(ctx, \"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 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)","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/util/template/expression_template.go#L210-L246","documentation":"expressionReplaceCore could not JSON-unmarshal the raw expression text (it is embedded in a JSON-marshaled template and must first be unescaped); the expression contains escapes that do not form a valid JSON string. If allowUnresolved were true the tag would pass through instead.","triggerScenarios":"Thrown at util/template/expression_template.go:228 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix escaping in the expression tag so it is a valid JSON string after marshalling","Avoid raw control characters or unbalanced escapes inside {{= ...}}"],"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"}