argoproj/argo-workflows · error

containers%s

Error message

containers%s

What it means

Every container in a ContainerSetTemplate must have a valid, non-empty Kubernetes-legal name. Validate() runs the collected container names through validateWorkflowFieldNames and prefixes any failure with "containers", propagating the detailed reason from that validator.

Source

Thrown at pkg/apis/workflow/v1alpha1/container_set_template_types.go:101

			return true
		}
	}
	return false
}

// Validate checks if the ContainerSetTemplate is valid
func (in *ContainerSetTemplate) Validate() error {
	if len(in.Containers) == 0 {
		return fmt.Errorf("containers must have at least one container")
	}

	names := make([]string, 0)
	for _, ctr := range in.Containers {
		names = append(names, ctr.Name)
	}
	err := validateWorkflowFieldNames(names, false)
	if err != nil {
		return fmt.Errorf("containers%s", err.Error())
	}

	// Ensure there are no collisions with volume mountPaths and artifact load paths
	mountPaths := make(map[string]string)
	for i, volMount := range in.VolumeMounts {
		if prev, ok := mountPaths[volMount.MountPath]; ok {
			return fmt.Errorf("volumeMounts[%d].mountPath '%s' already mounted in %s", i, volMount.MountPath, prev)
		}
		mountPaths[volMount.MountPath] = fmt.Sprintf("volumeMounts.%s", volMount.Name)
	}

	// Ensure the dependencies are defined
	nameToContainer := make(map[string]ContainerNode)
	for _, ctr := range in.Containers {
		nameToContainer[ctr.Name] = ctr
	}
	for _, ctr := range in.Containers {
		for _, depName := range ctr.Dependencies {

View on GitHub (pinned to 35bff19146)

Solutions

  1. Give each container a valid name: lowercase alphanumeric, '-' or '.', starting and ending alphanumeric (e.g. main, sidecar-logs).
  2. Read the suffix of the error message after "containers" for the exact validator complaint (empty or invalid index/name).
  3. Quote YAML scalar names if using characters the YAML parser may misinterpret.

Example fix

// before
containerSet:
  containers:
    - name: My_Container
      image: alpine
// after
containerSet:
  containers:
    - name: my-container
      image: alpine
Defensive patterns

Strategy: validation

Validate before calling

import "regexp"
var nameRe = regexp.MustCompile(`^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$`)
for _, c := range cs.ContainerSet.Containers {
    if c.Name == "" || !nameRe.MatchString(c.Name) {
        return fmt.Errorf("invalid container name %q", c.Name)
    }
}

Try / catch

if err := cs.Validate(); err != nil {
    if strings.HasPrefix(err.Error(), "containers") {
        // parse validator detail after prefix, fix the named container
    }
    return err
}

Prevention

When it happens

Trigger: A container entry missing metadata/name, or using an invalid DNS-1123-subdomain-style name (uppercase letters, underscores, leading/trailing dashes, slashes) inside containerSet.containers.

Common situations: Unquoted names with special characters in YAML; templated names with spaces or uppercase from variables; forgetting the name field on a container entry.

Related errors


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