{"record":{"id":"6052ec14a79a8d6e","repo":"hashicorp/nomad","slug":"volume-mount-references-an-empty-volume","errorCode":null,"errorMessage":"volume mount references an empty volume","messagePattern":"volume mount references an empty volume","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/volumes.go","lineNumber":26,"sourceCode":"\n\tmultierror \"github.com/hashicorp/go-multierror\"\n)\n\nconst (\n\tVolumeTypeHost = \"host\"\n\n\tVolumeMountPropagationPrivate       = \"private\"\n\tVolumeMountPropagationHostToTask    = \"host-to-task\"\n\tVolumeMountPropagationBidirectional = \"bidirectional\"\n\n\tSELinuxSharedVolume  = \"z\"\n\tSELinuxPrivateVolume = \"Z\"\n)\n\nvar (\n\terrVolMountInvalidPropagationMode = fmt.Errorf(\"volume mount has an invalid propagation mode\")\n\terrVolMountInvalidSELinuxLabel    = fmt.Errorf(\"volume mount has an invalid SELinux label\")\n\terrVolMountEmptyVol               = fmt.Errorf(\"volume mount references an empty volume\")\n)\n\n// ClientHostVolumeConfig is used to configure access to host paths on a Nomad Client\ntype ClientHostVolumeConfig struct {\n\tName     string `hcl:\",key\"`\n\tPath     string `hcl:\"path\"`\n\tReadOnly bool   `hcl:\"read_only\"`\n\t// ID is set for dynamic host volumes only.\n\tID string `hcl:\"-\"`\n}\n\nfunc (p *ClientHostVolumeConfig) Equal(o *ClientHostVolumeConfig) bool {\n\tif p == nil && o == nil {\n\t\treturn true\n\t}\n\tif p == nil || o == nil {\n\t\treturn false\n\t}","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/volumes.go#L8-L44","documentation":"This sentinel error errVolMountEmptyVol is returned directly by VolumeMount.Validate when the mount's Volume field is the empty string, i.e. the task references an undefined volume. Nomad requires every volume mount to name a volume declared in the task group.","triggerScenarios":"Calling Validate() on a VolumeMount with Volume == \"\" — e.g. a mount stanza in a job file that has no volume = \"...\" key, or programmatic construction of VolumeMount leaving Volume unset.","commonSituations":"Job specs with a mounts block whose volume key was deleted or never filled; templating tools that render an empty variable into volume = \"\"; renaming a group volume but not updating the mount reference (that case surfaces as a different error, but empty strings come from absent keys).","solutions":["Add or restore volume = \"<name>\" in the mount stanza, matching a volume declared in the task group.","Inspect the job file's mounts block for an empty or missing volume attribute.","If generating jobs programmatically, validate the volume name is non-empty before building the VolumeMount."],"exampleFix":"// before\nmount { target = \"/data\" }\n// after\nmount { target = \"/data\", volume = \"data\" }","handlingStrategy":"validation","validationCode":"if mount.Volume == \"\" {\n    return fmt.Errorf(\"mount must reference a declared volume\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set volume = \"<name>\" in each mount block.","Cross-check mount volume names against declared group volumes.","When templating, fail fast on empty volume variables."],"tags":["nomad","volumes","validation","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}