{"record":{"id":"1723a8b37c14f36e","repo":"argoproj/argo-workflows","slug":"failed-to-compile-workflow-template-parameter-s-e","errorCode":null,"errorMessage":"failed to compile workflow template parameter %s expression: %w","messagePattern":"failed to compile workflow template parameter (.+?) expression: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/event/dispatch/operation.go","lineNumber":151,"sourceCode":"\t\t}\n\n\t\tif wf.Name == \"\" {\n\t\t\twf.SetName(wf.GetGenerateName() + util.RandSuffix())\n\t\t}\n\n\t\t// users will always want to know why a workflow was submitted,\n\t\t// so we label with creator (which is a standard) and the name of the triggering event\n\t\t//nolint: contextcheck\n\t\tcreator.LabelCreator(o.ctx, wf)\n\t\tlabels.Label(wf, common.LabelKeyWorkflowEventBinding, wfeb.Name)\n\t\tif submit.Arguments != nil {\n\t\t\tfor _, p := range submit.Arguments.Parameters {\n\t\t\t\tif p.ValueFrom == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"malformed workflow template parameter \\\"%s\\\": valueFrom is nil\", p.Name)\n\t\t\t\t}\n\t\t\t\tprogram, compileErr := expr.Compile(p.ValueFrom.Event, expr.Env(o.env))\n\t\t\t\tif compileErr != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to compile workflow template parameter %s expression: %w\", p.Name, compileErr)\n\t\t\t\t}\n\t\t\t\tresult, runErr := expr.Run(program, o.env)\n\t\t\t\tif runErr != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to evaluate workflow template parameter \\\"%s\\\" expression: %w\", p.Name, runErr)\n\t\t\t\t}\n\t\t\t\tdata, marshalErr := json.Marshal(result)\n\t\t\t\tif marshalErr != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to convert result to JSON \\\"%s\\\" expression: %w\", p.Name, marshalErr)\n\t\t\t\t}\n\t\t\t\twf.Spec.Arguments.Parameters = append(wf.Spec.Arguments.Parameters, wfv1.Parameter{Name: p.Name, Value: wfv1.AnyStringPtr(wfv1.Item{Value: data})})\n\t\t\t}\n\t\t}\n\t\twf, err = client.ArgoprojV1alpha1().Workflows(wfeb.Namespace).Create(ctx, wf, metav1.CreateOptions{})\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create workflow: %w\", err)\n\t\t}\n\t\treturn wf, nil\n\t}","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/server/event/dispatch/operation.go#L133-L169","documentation":"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.","triggerScenarios":"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).","commonSituations":"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).","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."],"exampleFix":"# before (unknown variable + template syntax)\nvalueFrom:\n  event: '{{workflow.parameters.message}}'\n# after\nvalueFrom:\n  event: 'payload.message'","handlingStrategy":"validation","validationCode":"// pre-compile each valueFrom.event expression against the same env the dispatcher uses\nenv, _ := jsonutil.Jsonify(map[string]any{\"namespace\": ns, \"discriminator\": d, \"metadata\": map[string]any{}, \"payload\": payload})\nfor _, p := range wfeb.Spec.Submit.Arguments.Parameters {\n    if _, err := expr.Compile(p.ValueFrom.Event, expr.Env(env)); err != nil {\n        return fmt.Errorf(\"parameter %q expression invalid: %w\", p.Name, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["expr","expression-compile","workflow-event-binding","configuration","argo-workflows"],"backgroundTag":"expression-compile-error","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"}