argoproj/argo-workflows · error
failed to unmarshall JSON expression: %w
Error message
failed to unmarshall JSON expression: %w
What it means
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.
Source
Thrown at util/template/expression_template.go:228
if rv.Kind() == reflect.String {
if IsPlaceholder(rv.String()) {
shouldAllowFailure = true
return false
}
}
return true
})
log := logging.RequireLoggerFromContext(ctx)
// The template is JSON-marshaled. This JSON-unmarshals the expression to undo any character escapes.
var unmarshalledExpression string
err := json.Unmarshal(fmt.Appendf(nil, `"%s"`, expression), &unmarshalledExpression)
if err != nil && allowUnresolved {
log.WithError(err).Debug(ctx, "unresolved is allowed")
return fmt.Fprintf(w, "{{%s%s}}", kindExpression, expression)
}
if err != nil {
return 0, fmt.Errorf("failed to unmarshall JSON expression: %w", err)
}
varNameNotInEnv := anyVarNotInEnv(unmarshalledExpression, env)
if varNameNotInEnv != nil && allowUnresolved {
// this is to make sure expressions don't get resolved to nil or an empty string when certain variables
// don't exist in the env during the "global" replacement.
// See https://github.com/argoproj/argo-workflows/issues/5388, https://github.com/argoproj/argo-workflows/issues/15008,
// https://github.com/argoproj/argo-workflows/issues/10393, https://github.com/expr-lang/expr/issues/330
log.WithField("variable", *varNameNotInEnv).Debug(ctx, "variable not in env but unresolved is allowed")
return fmt.Fprintf(w, "{{%s%s}}", kindExpression, expression)
}
program, err := expr.Compile(unmarshalledExpression, expr.Env(env))
// This allowUnresolved check is not great
// it allows for errors that are obviously
// not failed reference checks to also pass
if err != nil && !allowUnresolved && !shouldAllowFailure {
return 0, fmt.Errorf("failed to evaluate expression: %w", err)View on GitHub (pinned to 35bff19146)
Solutions
- Fix escaping in the expression tag so it is a valid JSON string after marshalling
- Avoid raw control characters or unbalanced escapes inside {{= ...}}
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at util/template/expression_template.go:228 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/6e6ffb6813bfa50a.
Report an issue: GitHub.