argoproj/argo-workflows · error

failed to dispatch event: %v

Error message

failed to dispatch event: %v

What it means

Operation.Dispatch iterates all WorkflowEventBindings matching the namespace/discriminator and collects per-binding errors; if any binding failed, it aggregates and returns "failed to dispatch event: [errs]". Each failing binding also emits a Kubernetes Warning event 'WorkflowEventBindingError'. The message body is a Go slice of errors, so multiple failures appear as a printed list.

Source

Thrown at server/event/dispatch/operation.go:83

	logger.Debug(ctx, "Executing event dispatch")

	data, _ := json.MarshalIndent(o.env, "", "  ")
	logger.Debug(ctx, string(data))

	var errs []error
	for _, event := range o.events {
		err := waitutil.Backoff(retry.DefaultRetry, func() (bool, error) {
			_, err := o.dispatch(ctx, event)
			return !errorsutil.IsTransientErr(ctx, err), err
		})
		if err != nil {
			logger.WithError(err).WithFields(logging.Fields{"namespace": event.Namespace, "event": event.Name}).Error(ctx, "failed to dispatch from event")
			o.eventRecorder.Event(&event, corev1.EventTypeWarning, "WorkflowEventBindingError", "failed to dispatch event: "+err.Error())
			errs = append(errs, err)
		}
	}
	if len(errs) > 0 {
		return fmt.Errorf("failed to dispatch event: %v", errs)
	}
	return nil
}

func (o *Operation) dispatch(ctx context.Context, wfeb wfv1.WorkflowEventBinding) (*wfv1.Workflow, error) {
	logger := logging.RequireLoggerFromContext(ctx)

	selector := wfeb.Spec.Event.Selector
	matched, err := argoexpr.EvalBool(selector, o.env)
	if err != nil {
		return nil, fmt.Errorf("failed to evaluate workflow template expression: %w", err)
	}
	logger.WithFields(logging.Fields{"namespace": wfeb.Namespace, "event": wfeb.Name, "selector": selector, "matched": matched}).Debug(ctx, "Selector evaluation")
	submit := wfeb.Spec.Submit
	if matched && submit != nil {
		//nolint: contextcheck
		client := auth.GetWfClient(o.ctx)
		ref := wfeb.Spec.Submit.WorkflowTemplateRef

View on GitHub (pinned to 35bff19146)

Solutions

  1. Read the bracketed inner errors in the message and the 'WorkflowEventBindingError' events: `kubectl get events -n <ns> | grep WorkflowEventBindingError`.
  2. Fix each binding's selector (`spec.event.selector`) to match the actual payload shape, guarding optional fields, e.g. `payload.foo != nil && payload.foo == "bar"`.
  3. Verify the referenced WorkflowTemplate/ClusterWorkflowTemplate exists and validates (`argo lint`).
  4. Check argo-server RBAC can create Workflows in the namespace.
  5. Re-drive the event with `argo events test` after fixing to confirm.

Example fix

# before: selector breaks when field absent
selector: payload.head_commit.id == "abc"
# after
selector: payload.head_commit != nil && payload.head_commit.id == "abc"
Defensive patterns

Strategy: try-catch

Validate before calling

// check for failing bindings' events before re-driving
events, _ := clientset.CoreV1().Events(ns).Search(scheme.Scheme,
	&corev1.ObjectReference{Kind: "WorkflowEventBinding", Name: wfebName})
for _, e := range events {
	if e.Reason == "WorkflowEventBindingError" { /* fix cause before retry */ }
}

Try / catch

err := op.Dispatch()
if err != nil {
	// message contains "failed to dispatch event: [errs...]"
	// read per-binding inner errors and Kubernetes warning events
	return fmt.Errorf("event processing failed: %w", err)
}

Prevention

When it happens

Trigger: One or more WorkflowEventBindings in the namespace fail during dispatch: selector evaluation error (309), workflow submit failure (RBAC, invalid generated workflow, missing template), or a timeout — any binding error causes this aggregate.

Common situations: A selector referencing payload fields that don't exist on that event's payload; submit referencing a WorkflowTemplate that was deleted; RBAC changes breaking the server's ability to create workflows in the namespace; malformed submit.workflowTemplateRef.

Related errors


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/03c922874925ea4e. Report an issue: GitHub.