argoproj/argo-workflows · error

expected labels of the form: NAME1=VALUE2,NAME2=VALUE2. Rece

Error message

expected labels of the form: NAME1=VALUE2,NAME2=VALUE2. Received: %s: %w

What it means

ApplySubmitOpts parses opts.Labels with the same label syntax as kubectl (NAME1=VALUE1,NAME2=VALUE2). If ParseLabels fails — malformed pairs, missing '=', invalid key/value characters — the error is wrapped with this message including the offending input.

Source

Thrown at workflow/util/util.go:275

	if opts.ServiceAccount != "" {
		wf.Spec.ServiceAccountName = opts.ServiceAccount
	}
	if opts.PodPriorityClassName != "" {
		wf.Spec.PodPriorityClassName = opts.PodPriorityClassName
	}

	if opts.Priority != nil {
		wf.Spec.Priority = opts.Priority
	}

	wfLabels := wf.GetLabels()
	if wfLabels == nil {
		wfLabels = make(map[string]string)
	}
	if opts.Labels != "" {
		passedLabels, err := cmdutil.ParseLabels(opts.Labels)
		if err != nil {
			return fmt.Errorf("expected labels of the form: NAME1=VALUE2,NAME2=VALUE2. Received: %s: %w", opts.Labels, err)
		}
		maps.Copy(wfLabels, passedLabels)
	}
	wf.SetLabels(wfLabels)
	wfAnnotations := wf.GetAnnotations()
	if wfAnnotations == nil {
		wfAnnotations = make(map[string]string)
	}
	if opts.Annotations != "" {
		passedAnnotations, err := cmdutil.ParseLabels(opts.Annotations)
		if err != nil {
			return fmt.Errorf("expected Annotations of the form: NAME1=VALUE2,NAME2=VALUE2. Received: %s: %w", opts.Labels, err)
		}
		maps.Copy(wfAnnotations, passedAnnotations)
	}
	wf.SetAnnotations(wfAnnotations)
	err := overrideParameters(wf, opts.Parameters)
	if err != nil {

View on GitHub (pinned to 35bff19146)

Solutions

  1. Format labels as comma-separated KEY=VALUE pairs: --labels foo=bar,baz=qux
  2. Quote the argument in your shell: --labels "app=my-app,env=prod"
  3. Validate keys/values against Kubernetes label rules (alphanumerics, '-', '_', '.', optional prefix)

Example fix

// before
argo submit wf.yaml --labels app=myapp env=prod
// after
argo submit wf.yaml --labels "app=myapp,env=prod"
Defensive patterns

Strategy: validation

Validate before calling

for _, pair := range strings.Split(labelsArg, ",") {
    if !strings.Contains(pair, "=") || strings.SplitN(pair, "=", 2)[0] == "" {
        return fmt.Errorf("invalid label pair %q; use NAME=VALUE,NAME=VALUE", pair)
    }
}

Try / catch

err := util.ApplySubmitOpts(wf, opts)
if err != nil && strings.Contains(err.Error(), "expected labels of the form") {
    return fmt.Errorf("fix --labels flag: %w", err)
}

Prevention

When it happens

Trigger: argo submit --labels with a malformed value, e.g. --labels foo (no =), or a key/value violating Kubernetes label validation (bad characters, too long, empty key) via CreateCronWorkflows/submitWorkflows/SubmitWorkflow.

Common situations: Shell quoting issues turning 'a=b,c=d' into 'a=b c=d'; commas inside values; copying labels from JSON into the flag; invalid label characters like '/' or uppercase in unexpected places.

Related errors


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