{"record":{"id":"f611d27deae45ba2","repo":"argoproj/argo-workflows","slug":"failed-to-evaluate-workflow-template-parameter-s","errorCode":null,"errorMessage":"failed to evaluate workflow template parameter \"%s\" expression: %w","messagePattern":"failed to evaluate workflow template parameter \"(.+?)\" expression: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/event/dispatch/operation.go","lineNumber":155,"sourceCode":"\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}\n\treturn nil, nil\n}\n\nfunc (o *Operation) populateWorkflowMetadata(wf *wfv1.Workflow, metadata *metav1.ObjectMeta) error {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/server/event/dispatch/operation.go#L137-L173","documentation":"The parameter expression compiled successfully but failed at runtime when expr.Run executed it against the dispatch environment. This happens for runtime errors: nil pointer/index into missing payload fields, type mismatches (e.g. arithmetic on a string), calling methods on null, or out-of-range access. The dispatch aborts and a Warning event is recorded on the binding.","triggerScenarios":"valueFrom.event performs operations on data absent from the actual event payload (e.g. `payload.body.foo` when body is null), assumes a numeric type where the payload delivered a string, or divides/indexes invalidly — triggered whenever an event with an unexpected shape matches the binding selector.","commonSituations":"Eventsource payload schema changed (field renamed/removed) while the binding still references the old path; webhook sent a different JSON shape than tested; JSON-normalized env turning expected numbers into strings; optional fields accessed without nil-guards.","solutions":["Add nil-safety with expr's `??` default operator or check existence: `payload.body ?? {}`, `payload.body.foo ?? 'default'`.","Coerce types explicitly in the expression, e.g. `int(payload.count)` or `string(payload.id)`, to match expected operations.","Log/inspect the actual payload: enable debug logging on the argo-server (it logs the env JSON at Debug level in Dispatch) or view the event payload from the eventsource, then align the expression paths.","Update the WorkflowEventBinding to match the current payload schema and re-trigger the event to confirm dispatch succeeds."],"exampleFix":"# before: crashes when body is missing\nvalueFrom:\n  event: 'payload.body.message'\n# after\nvalueFrom:\n  event: '(payload.body ?? {}).message ?? \"\"'","handlingStrategy":"try-catch","validationCode":"// harden expressions: defaults and type coercion\n// valueFrom.event: '(payload.body ?? {}).message ?? \"\"'\n// valueFrom.event: 'int(payload.count ?? 0)'","typeGuard":null,"tryCatchPattern":"// in callers that trigger dispatch, tolerate per-binding failure and alert\nif err := op.Dispatch(ctx); err != nil {\n    logger.WithError(err).Error(ctx, \"event dispatch failed\")\n    // surface via WorkflowEventBinding Warning event for operator visibility\n}","preventionTips":["Use ?? defaults and (x ?? {}) guards around every optional payload field.","Coerce types explicitly (int(), string()) instead of assuming payload types.","Version-gate payload schema changes from eventsource producers; update bindings in the same change.","Watch WorkflowEventBindingError events; they carry the exact expression runtime message with the parameter name."],"tags":["expr","runtime-error","nil-pointer","workflow-event-binding","argo-workflows"],"backgroundTag":"expression-runtime-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"}