{"record":{"id":"647b479b26ff766c","repo":"argoproj/argo-workflows","slug":"400-647b47","errorCode":"400","errorMessage":"volume '%s' not found in workflow spec","messagePattern":"volume '(.+?)' not found in workflow spec","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/controller/workflowpod.go","lineNumber":1478,"sourceCode":"\t\tfor _, vol := range vols {\n\t\t\tif vol.Name == name {\n\t\t\t\treturn &vol\n\t\t\t}\n\t\t}\n\t\t// Find a volume from pvcs.\n\t\tfor _, pvc := range pvcs {\n\t\t\tif pvc.Name == name {\n\t\t\t\treturn &pvc\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\taddVolumeRef := func(volMounts []apiv1.VolumeMount) error {\n\t\tfor _, volMnt := range volMounts {\n\t\t\tvol := getVolByName(volMnt.Name)\n\t\t\tif vol == nil {\n\t\t\t\treturn errors.Errorf(errors.CodeBadRequest, \"volume '%s' not found in workflow spec\", volMnt.Name)\n\t\t\t}\n\t\t\tfound := false\n\t\t\tfor _, v := range pod.Spec.Volumes {\n\t\t\t\tif v.Name == vol.Name {\n\t\t\t\t\tfound = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !found {\n\t\t\t\tif pod.Spec.Volumes == nil {\n\t\t\t\t\tpod.Spec.Volumes = make([]apiv1.Volume, 0)\n\t\t\t\t}\n\t\t\t\tpod.Spec.Volumes = append(pod.Spec.Volumes, *vol)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n","sourceCodeStart":1460,"sourceCodeEnd":1496,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/controller/workflowpod.go#L1460-L1496","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the missing volume to spec.volumes in the workflow","Remove the dangling volumeMount from the template/patch","If added via podSpecPatch, patch /volumes as well"],"exampleFix":"// before\nspec:\n  templates:\n    - name: main\n      container:\n        volumeMounts:\n          - name: workdir\n            mountPath: /mnt\n// after\nspec:\n  volumes:\n    - name: workdir\n      emptyDir: {}\n  templates:\n    - name: main\n      container:\n        volumeMounts:\n          - name: workdir\n            mountPath: /mnt","handlingStrategy":"validation","validationCode":"// ensure every volumeMount has a matching volume\nvolNames := set(volumes.map(v => v.name))\nfor (const m of container.volumeMounts) {\n  if (!volNames.has(m.name)) throw new Error(`volume '${m.name}' not defined`)\n}","typeGuard":null,"tryCatchPattern":"if err := addVolumeRef(container.VolumeMounts); err != nil {\n  return fmt.Errorf(\"invalid volumes: %w\", err)\n}","preventionTips":["Declare every volume referenced by any volumeMount in spec.volumes","When patching containers via podSpecPatch, patch /volumes too","Audit workflowTemplate default containers for volume expectations"],"tags":["kubernetes","volumes","pod-build","argo-workflows"],"backgroundTag":"volume-not-defined","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"}