{"record":{"id":"764157fa8c5dd505","repo":"hashicorp/nomad","slug":"error-querying-host-volume-w","errorCode":null,"errorMessage":"Error querying host volume: %w","messagePattern":"Error querying host volume: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/volume_status_host.go","lineNumber":46,"sourceCode":"\n\t// get a host volume that matches the given prefix or a list of all matches\n\t// if an exact match is not found. note we can't use the shared getByPrefix\n\t// helper here because the List API doesn't match the required signature\n\tvolStub, possible, err := getHostVolumeByPrefix(client, id, c.namespace)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%w: %w\", hostVolumeListError, err)\n\t}\n\tif len(possible) > 0 {\n\t\tout, err := formatHostVolumes(possible, opts)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error formatting: %w\", err)\n\t\t}\n\t\treturn fmt.Errorf(\"Prefix matched multiple host volumes\\n\\n%s\", out)\n\t}\n\n\tvol, _, err := client.HostVolumes().Get(volStub.ID, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error querying host volume: %w\", err)\n\t}\n\n\tstr, err := formatHostVolume(vol, opts)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error formatting host volume: %w\", err)\n\t}\n\tc.Ui.Output(c.Colorize().Color(str))\n\treturn nil\n}\n\nfunc (c *VolumeStatusCommand) hostVolumeList(client *api.Client, nodeID, nodePool string, opts formatOpts) error {\n\tif !(opts.json || len(opts.template) > 0) {\n\t\tc.Ui.Output(c.Colorize().Color(\"[bold]Dynamic Host Volumes[reset]\"))\n\t}\n\n\tvols, _, err := client.HostVolumes().List(&api.HostVolumeListRequest{\n\t\tNodeID:   nodeID,\n\t\tNodePool: nodePool,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_status_host.go#L28-L64","documentation":"hostVolumeStatus wrapper: getHostVolumeByPrefix returned an error while querying or disambiguating the requested host volume prefix/ID; it is combined with hostVolumeListError via %w so callers can match the sentinel.","triggerScenarios":"Prefix matched exactly one volume (or exact match), then HostVolumes().Get fails: volume deleted between List and Get, ACL lacking host-volume read on that volume/namespace, agent or server RPC failure.","commonSituations":"Race where the volume was deregistered moments before; token scoped to a different namespace; transient server unavailability during the two-step lookup.","solutions":["Read the wrapped error: 404 -> re-list to confirm the volume still exists; 403 -> fix ACL token/namespace","Retry the command; the failure may be transient between the List and Get calls","Verify NOMAD_NAMESPACE and token permissions cover the target volume"],"exampleFix":"// before\nnomad volume status host vol-abc  # 403\n// after\nexport NOMAD_TOKEN=<token-with-host-volume-read>\nexport NOMAD_NAMESPACE=default\nnomad volume status host vol-abc","handlingStrategy":"retry","validationCode":"// verify the volume still exists right before Get\nstubs, _, err := client.HostVolumes().List(nil)\nif err != nil || !containsID(stubs, id) { /* abort or re-resolve */ }","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil {\n    if strings.Contains(err.Error(), \"Error querying host volume\") {\n        if strings.Contains(err.Error(), \"404\") { /* re-list: volume vanished */ } else if strings.Contains(err.Error(), \"403\") { /* fix ACL/namespace */ }\n    }\n}","preventionTips":["Retry once on transient errors between List and Get","Keep token/namespace consistent across the whole lookup","Handle the delete-race: treat 404 as 'gone', not a bug"],"tags":["cli","api","acl","host-volumes"],"backgroundTag":"api-request-failed","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"}