{"record":{"id":"83ef9bfdb9b68e4e","repo":"hashicorp/nomad","slug":"volume-mount-d-is-invalid-w","errorCode":null,"errorMessage":"Volume Mount (%d) is invalid: \"%w\"","messagePattern":"Volume Mount \\((.+?)\\) is invalid: \"%w\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":8402,"sourceCode":"\t\tif t.Leader {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Connect proxy task must not have leader set\"))\n\t\t}\n\n\t\t// Ensure the proxy task has a corresponding service entry\n\t\tserviceErr := ValidateConnectProxyService(t.Kind.Value(), tg.Services)\n\t\tif serviceErr != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, serviceErr)\n\t\t}\n\t}\n\n\t// Validation for volumes\n\tfor idx, vm := range t.VolumeMounts {\n\t\tif _, ok := tg.Volumes[vm.Volume]; !ok {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Volume Mount (%d) references undefined volume %s\", idx, vm.Volume))\n\t\t}\n\n\t\tif err := vm.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Volume Mount (%d) is invalid: \\\"%w\\\"\", idx, err))\n\t\t}\n\t}\n\n\t// Validate CSI Plugin Config\n\tif t.CSIPluginConfig != nil {\n\t\tif t.CSIPluginConfig.ID == \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"CSIPluginConfig must have a non-empty PluginID\"))\n\t\t}\n\n\t\tif !CSIPluginTypeIsValid(t.CSIPluginConfig.Type) {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"CSIPluginConfig PluginType must be one of 'node', 'controller', or 'monolith', got: \\\"%s\\\"\", t.CSIPluginConfig.Type))\n\t\t}\n\n\t\tif t.CSIPluginConfig.StagePublishBaseDir != \"\" && t.CSIPluginConfig.MountDir != \"\" &&\n\t\t\thelper.IsSubdirectory(t.CSIPluginConfig.MountDir, t.CSIPluginConfig.StagePublishBaseDir) {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"CSIPluginConfig StagePublishBaseDir must not be a subdirectory of MountDir, got: StagePublishBaseDir=\\\"%s\\\" MountDir=\\\"%s\\\"\", t.CSIPluginConfig.StagePublishBaseDir, t.CSIPluginConfig.MountDir))\n\t\t}\n","sourceCodeStart":8384,"sourceCodeEnd":8420,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L8384-L8420","documentation":"After existence-checking, Task.Validate runs VolumeMount.Validate for each mount and wraps failures as \"Volume Mount (%d) is invalid: \\\"%w\\\"\". This catches invalid mount properties even when the volume itself is defined, e.g. missing destination, bad propagation mode, or SELinux/readonly constraints.","triggerScenarios":"A task volume_mount has an empty `destination`, an invalid `propagation_mode`, or other field failing VolumeMount.Validate, while the referenced group volume exists.","commonSituations":"Omitting destination inside the container; setting propagation_mode to an unsupported string; mount options incompatible with the volume type (host vs CSI).","solutions":["Read the wrapped inner error for the exact invalid mount field","Set a valid `destination` path inside the task for the mount","Use propagation_mode only where supported (host volumes) and with valid values (private/host-to-task)"],"exampleFix":"// before\nvolume_mount {\n  volume = \"data\"\n}\n// after\nvolume_mount {\n  volume      = \"data\"\n  destination = \"/data\"\n}","handlingStrategy":"validation","validationCode":"for i, vm := range task.VolumeMounts {\n    if err := vm.Validate(); err != nil {\n        return fmt.Errorf(\"volume_mount %d: %w\", i, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := job.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"is invalid:\") && strings.Contains(err.Error(), \"Volume Mount\") { /* fix mount fields */ }\n}","preventionTips":["Always set destination on volume_mount","Use documented propagation_mode values only","Match mount options to the volume type (host vs CSI)"],"tags":["nomad","volume","csi","job-validation"],"backgroundTag":"volume-mount-invalid","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"}