argoproj/argo-workflows · error

400

400

Error message

volume '%s' not found in workflow spec

What it means

When assembling the pod, every container's volumeMount must resolve to a volume declared in the workflow spec (or added by Argo itself). If a volumeMount references a volume name that getVolByName cannot find anywhere in the spec, the controller returns 400 Bad Request naming the missing volume.

Source

Thrown at workflow/controller/workflowpod.go:1478

		for _, vol := range vols {
			if vol.Name == name {
				return &vol
			}
		}
		// Find a volume from pvcs.
		for _, pvc := range pvcs {
			if pvc.Name == name {
				return &pvc
			}
		}
		return nil
	}

	addVolumeRef := func(volMounts []apiv1.VolumeMount) error {
		for _, volMnt := range volMounts {
			vol := getVolByName(volMnt.Name)
			if vol == nil {
				return errors.Errorf(errors.CodeBadRequest, "volume '%s' not found in workflow spec", volMnt.Name)
			}
			found := false
			for _, v := range pod.Spec.Volumes {
				if v.Name == vol.Name {
					found = true
					break
				}
			}
			if !found {
				if pod.Spec.Volumes == nil {
					pod.Spec.Volumes = make([]apiv1.Volume, 0)
				}
				pod.Spec.Volumes = append(pod.Spec.Volumes, *vol)
			}
		}
		return nil
	}

View on GitHub (pinned to 35bff19146)

Solutions

  1. Add the missing volume to spec.volumes in the workflow
  2. Remove the dangling volumeMount from the template/patch
  3. If added via podSpecPatch, patch /volumes as well

Example fix

// before
spec:
  templates:
    - name: main
      container:
        volumeMounts:
          - name: workdir
            mountPath: /mnt
// after
spec:
  volumes:
    - name: workdir
      emptyDir: {}
  templates:
    - name: main
      container:
        volumeMounts:
          - name: workdir
            mountPath: /mnt
Defensive patterns

Strategy: validation

Validate before calling

// ensure every volumeMount has a matching volume
volNames := set(volumes.map(v => v.name))
for (const m of container.volumeMounts) {
  if (!volNames.has(m.name)) throw new Error(`volume '${m.name}' not defined`)
}

Try / catch

if err := addVolumeRef(container.VolumeMounts); err != nil {
  return fmt.Errorf("invalid volumes: %w", err)
}

Prevention

When it happens

Trigger: A template (or its containers/volumes merged from podSpecPatch, workflowTemplate defaults, or runtime-injected containers) mounts volumeMounts.name that has no matching entry in spec.volumes or configMap-injected volumes.

Common situations: Adding a volumeMount via podSpecPatch without adding the volume to spec.volumes; containerSet templates referencing volumes deleted during refactoring; workflowTemplates with default containers expecting volumes the workflow doesn't declare.

Related errors


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