{"record":{"id":"08a11160307ecf3f","repo":"hashicorp/nomad","slug":"invalid-access-mode-q","errorCode":null,"errorMessage":"invalid access mode: %q","messagePattern":"invalid access mode: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/host_volumes.go","lineNumber":335,"sourceCode":"func (hvc *HostVolumeCapability) Validate() error {\n\tif hvc == nil {\n\t\treturn errors.New(\"validate called on nil host volume capability\")\n\t}\n\n\tswitch hvc.AttachmentMode {\n\tcase HostVolumeAttachmentModeBlockDevice,\n\t\tHostVolumeAttachmentModeFilesystem:\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid attachment mode: %q\", hvc.AttachmentMode)\n\t}\n\n\tswitch hvc.AccessMode {\n\tcase HostVolumeAccessModeSingleNodeReader,\n\t\tHostVolumeAccessModeSingleNodeWriter,\n\t\tHostVolumeAccessModeSingleNodeSingleWriter,\n\t\tHostVolumeAccessModeSingleNodeMultiWriter:\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid access mode: %q\", hvc.AccessMode)\n\t}\n\n\treturn nil\n}\n\n// HostVolumeAttachmentModes choose the type of storage API that will be used to\n// interact with the device.\nconst (\n\tHostVolumeAttachmentModeUnknown     VolumeAttachmentMode = \"\"\n\tHostVolumeAttachmentModeBlockDevice VolumeAttachmentMode = \"block-device\"\n\tHostVolumeAttachmentModeFilesystem  VolumeAttachmentMode = \"file-system\"\n)\n\n// HostVolumeAccessModes indicate how Nomad should make the volume available to\n// concurrent allocations.\nconst (\n\tHostVolumeAccessModeUnknown VolumeAccessMode = \"\"\n","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/host_volumes.go#L317-L353","documentation":"HostVolume capability validation ensures AccessMode is one of the supported single-node modes: single-node-reader, single-node-writer, single-node-single-writer, or single-node-multi-writer. Any other value returns this error.","triggerScenarios":"Registering or validating a host volume whose Capabilities entry has an AccessMode outside the four HostVolumeAccessModeSingleNode* constants.","commonSituations":"Using CSI multi-node access modes (e.g. multi-node-multi-writer) on a host volume; typo like 'single-node-reader-writer'.","solutions":["Set access_mode to one of: single-node-reader, single-node-writer, single-node-single-writer, single-node-multi-writer","If multi-node access is required, use a CSI volume instead of a host volume","Run nomad volume validate to confirm the spec"],"exampleFix":"// before\ncapability { attachment_mode = \"filesystem\" access_mode = \"multi-node-multi-writer\" }\n// after\ncapability { attachment_mode = \"filesystem\" access_mode = \"single-node-writer\" }","handlingStrategy":"validation","validationCode":"validAccess := map[string]bool{\n  \"single-node-reader\": true, \"single-node-writer\": true,\n  \"single-node-single-writer\": true, \"single-node-multi-writer\": true}\nif !validAccess[cap.AccessMode] {\n  return fmt.Errorf(\"bad access_mode %q\", cap.AccessMode)\n}","typeGuard":"func validAccessMode(m string) bool {\n  switch m {\n  case \"single-node-reader\", \"single-node-writer\",\n    \"single-node-single-writer\", \"single-node-multi-writer\":\n    return true\n  }\n  return false\n}","tryCatchPattern":null,"preventionTips":["Never reuse CSI multi-node access modes for host volumes","Centralize capability enums in one config package","Run validation before every volume registration"],"tags":["nomad","validation","host-volume","access-mode"],"backgroundTag":"invalid-enum-value","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"}