argoproj/argo-workflows · error
failed to compile workflow template parameter %s expression:
Error message
failed to compile workflow template parameter %s expression: %w
What it means
The parameter's `valueFrom.event` string is compiled with the expr-lang library against the dispatch environment (`namespace`, `discriminator`, `metadata`, `payload`). A compile-time error means the expression is syntactically invalid or references names/types not present in that environment, so the event cannot be dispatched. This fails fast before evaluation.
Source
Thrown at server/event/dispatch/operation.go:151
}
if wf.Name == "" {
wf.SetName(wf.GetGenerateName() + util.RandSuffix())
}
// users will always want to know why a workflow was submitted,
// so we label with creator (which is a standard) and the name of the triggering event
//nolint: contextcheck
creator.LabelCreator(o.ctx, wf)
labels.Label(wf, common.LabelKeyWorkflowEventBinding, wfeb.Name)
if submit.Arguments != nil {
for _, p := range submit.Arguments.Parameters {
if p.ValueFrom == nil {
return nil, fmt.Errorf("malformed workflow template parameter \"%s\": valueFrom is nil", p.Name)
}
program, compileErr := expr.Compile(p.ValueFrom.Event, expr.Env(o.env))
if compileErr != nil {
return nil, fmt.Errorf("failed to compile workflow template parameter %s expression: %w", p.Name, compileErr)
}
result, runErr := expr.Run(program, o.env)
if runErr != nil {
return nil, fmt.Errorf("failed to evaluate workflow template parameter \"%s\" expression: %w", p.Name, runErr)
}
data, marshalErr := json.Marshal(result)
if marshalErr != nil {
return nil, fmt.Errorf("failed to convert result to JSON \"%s\" expression: %w", p.Name, marshalErr)
}
wf.Spec.Arguments.Parameters = append(wf.Spec.Arguments.Parameters, wfv1.Parameter{Name: p.Name, Value: wfv1.AnyStringPtr(wfv1.Item{Value: data})})
}
}
wf, err = client.ArgoprojV1alpha1().Workflows(wfeb.Namespace).Create(ctx, wf, metav1.CreateOptions{})
if err != nil {
return nil, fmt.Errorf("failed to create workflow: %w", err)
}
return wf, nil
}View on GitHub (pinned to 35bff19146)
Solutions
- Fix the expression syntax; valid root variables are namespace, discriminator, metadata, payload (e.g. `payload.message`, `metadata["x-github-action"]`).
- Test the expression against a real payload with `argo submit --from eventbinding/<name>` after triggering, or validate with the expr REPL using the same env keys.
- Remember the env is JSON-normalized: nested keys are lowercase and dynamic fields may be typed null — access with safe indexing or `??` defaults.
- Do not use {{...}} template syntax here; WorkflowEventBinding parameters use pure expr expressions.
Example fix
# before (unknown variable + template syntax)
valueFrom:
event: '{{workflow.parameters.message}}'
# after
valueFrom:
event: 'payload.message' Defensive patterns
Strategy: validation
Validate before calling
// pre-compile each valueFrom.event expression against the same env the dispatcher uses
env, _ := jsonutil.Jsonify(map[string]any{"namespace": ns, "discriminator": d, "metadata": map[string]any{}, "payload": payload})
for _, p := range wfeb.Spec.Submit.Arguments.Parameters {
if _, err := expr.Compile(p.ValueFrom.Event, expr.Env(env)); err != nil {
return fmt.Errorf("parameter %q expression invalid: %w", p.Name, err)
}
} Prevention
- Only use the four env roots: namespace, discriminator, metadata, payload — no {{...}} template syntax.
- Lint expressions in CI with expr.Compile against a representative sample payload.
- Remember the env is JSON-normalized; assume lowercase keys and nullable dynamic fields.
- Test end-to-end with a real event before promoting the binding.
When it happens
Trigger: valueFrom.event contains expr syntax errors (unbalanced quotes/parens, bad operators), references unknown variables (e.g. `event.body` instead of `payload`), or uses types/fields in ways expr's type checking against expr.Env(o.env) rejects (o.env is JSON-normalized, so fields are lowercase/null-typed).
Common situations: Writing workflow-level Argo templates syntax (`{{workflow.parameters.x}}`) instead of expr; referencing a payload field that isn't in the env so expr type-checking fails; single vs double quote confusion in YAML; using functions not available in the plain expr env (some only exist via exprenv.GetFuncMap used for metadata strings, not here).
Related errors
- malformed workflow template parameter "%s": valueFrom is nil
- failed to evaluate workflow template parameter "%s" expressi
- failed to evaluate workflow %s expression: %w
- must specify at least one auth mode
- failed to get workflow template: %w
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/1723a8b37c14f36e.
Report an issue: GitHub.