{"record":{"id":"c68fe637ba818865","repo":"hashicorp/nomad","slug":"no-such-volume-s","errorCode":null,"errorMessage":"no such volume: %s","messagePattern":"no such volume: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/host_volume_endpoint.go","lineNumber":699,"sourceCode":"\n\tif args.VolumeID == \"\" {\n\t\treturn fmt.Errorf(\"missing volume ID to delete\")\n\t}\n\n\tsnap, err := v.srv.State().Snapshot()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tns := args.RequestNamespace()\n\tid := args.VolumeID\n\n\tvol, err := snap.HostVolumeByID(nil, ns, id, true)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not query host volume: %w\", err)\n\t}\n\tif vol == nil {\n\t\treturn fmt.Errorf(\"no such volume: %s\", id)\n\t}\n\tif len(vol.Allocations) > 0 {\n\t\tallocIDs := helper.ConvertSlice(vol.Allocations,\n\t\t\tfunc(a *structs.AllocListStub) string { return a.ID })\n\t\treturn fmt.Errorf(\"volume %s in use by allocations: %v\", id, allocIDs)\n\t}\n\n\t// serialize client RPC and raft write per volume ID\n\tindex, err := v.serializeCall(vol.ID, \"delete\", func() (uint64, error) {\n\t\tif err := v.deleteVolume(vol); err != nil {\n\t\t\tif structs.IsErrUnknownNode(err) || structs.IsErrNoNodeConn(err) {\n\t\t\t\tif !args.Force {\n\t\t\t\t\treturn 0, fmt.Errorf(\n\t\t\t\t\t\t\"volume cannot be removed from unknown node without force=true\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn 0, err\n\t\t\t}","sourceCodeStart":681,"sourceCodeEnd":717,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/host_volume_endpoint.go#L681-L717","documentation":"After a successful lookup, HostVolume.Delete checks whether the volume exists in the namespace; a nil result means there is nothing to delete, so it returns 'no such volume: <id>'. This is the expected error when the ID/namespace pair doesn't match any registered host volume.","triggerScenarios":"Deleting with a volume ID that doesn't exist, using the wrong -namespace, deleting an already-deleted volume, or passing a volume name where an ID is required.","commonSituations":"Typo'd or truncated ID; volume created in a different namespace; double-delete in automation races; switching clusters/regions where the volume doesn't exist.","solutions":["Verify the volume exists: `nomad host volume status <id> -namespace <ns>` and confirm the exact ID and namespace.","Correct the -namespace flag to the volume's actual namespace.","Make deletion idempotent in automation — treat 'no such volume' as already-deleted success."],"exampleFix":"// before\nerr := delete(ns=\"prod\", id) // volume lives in \"default\"\n// after\nerr := delete(ns=\"default\", id)\n// or idempotent:\nif err != nil && strings.Contains(err.Error(), \"no such volume\") { err = nil }","handlingStrategy":"validation","validationCode":"vol, _, err := client.HostVolumes().Info(id, nil, nil)\nif err != nil || vol == nil {\n    return fmt.Errorf(\"volume %s not found in namespace %q; skip delete\", id, ns)\n}","typeGuard":null,"tryCatchPattern":"err := client.HostVolumes().Delete(ns, id, nil)\nif err != nil && strings.Contains(err.Error(), \"no such volume\") {\n    log.Printf(\"volume %s already deleted; treating as success\", id)\n    err = nil // idempotent delete\n}","preventionTips":["Always pass the correct -namespace alongside the volume ID.","Make delete pipelines idempotent (ignore 'no such volume').","Look up IDs by name with `nomad host volume status` before deleting."],"tags":["nomad","host-volumes","not-found","delete"],"backgroundTag":"resource-not-found","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"}