{"record":{"id":"91fff047b6a87d73","repo":"hashicorp/nomad","slug":"error-querying-csi-volume-w","errorCode":null,"errorMessage":"Error querying CSI volume: %w","messagePattern":"Error querying CSI volume: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/volume_status_csi.go","lineNumber":45,"sourceCode":"\t\t&api.QueryOptions{\n\t\t\tPrefix:    id,\n\t\t\tNamespace: c.namespace,\n\t\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error listing CSI volumes: %w\", err)\n\t}\n\tif len(possible) > 0 {\n\t\tout, err := csiFormatVolumes(possible, c.json, c.template)\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 CSI volumes\\n\\n%s\", out)\n\t}\n\n\t// Try querying the volume\n\tvol, _, err := client.CSIVolumes().Info(volStub.ID, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error querying CSI volume: %w\", err)\n\t}\n\n\tstr, err := c.formatCSIBasic(vol)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error formatting CSI volume: %w\", err)\n\t}\n\tc.Ui.Output(str)\n\treturn nil\n}\n\nfunc (c *VolumeStatusCommand) csiVolumesList(client *api.Client, opts formatOpts) error {\n\n\tif !(opts.json || len(opts.template) > 0) {\n\t\tc.Ui.Output(c.Colorize().Color(\"[bold]Container Storage Interface[reset]\"))\n\t}\n\n\tvols, _, err := client.CSIVolumes().List(nil)\n\tif err != nil {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_status_csi.go#L27-L63","documentation":"After the prefix match resolves to a single volume, csiVolumeStatus calls client.CSIVolumes().Info(volStub.ID) to fetch the full volume. Any API error (deleted volume between list and info, ACL denial, network failure) is wrapped as `Error querying CSI volume`.","triggerScenarios":"`nomad volume status <exact-prefix>` where the follow-up Info call fails: the volume was deregistered after listing, the token lacks read capability for the volume's namespace, or the agent/server request errored.","commonSituations":"Stale CLI output — volume removed by another operator between commands; namespace mismatch between token and volume; transient server unavailability.","solutions":["Read the wrapped cause: re-register the volume if it was deregistered, or retry if transient.","Confirm the ACL token can read volumes in the volume's namespace.","Verify the volume still exists with `nomad volume status` (list) and use its current ID."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// confirm the volume still exists right before Info\nstubs, _, err := client.CSIVolumes().List(&api.QueryOptions{Prefix: volID})\nif err != nil || len(stubs) == 0 { return fmt.Errorf(\"volume %s no longer exists\", volID) }","typeGuard":null,"tryCatchPattern":"var vol *api.CSIVolume\nfor i := 0; i < 3; i++ {\n\tv, _, err := client.CSIVolumes().Info(id, nil)\n\tif err == nil { vol = v; break }\n\tif strings.Contains(err.Error(), \"404\") { return fmt.Errorf(\"volume deregistered\") }\n\ttime.Sleep(time.Duration(1<<i) * 100 * time.Millisecond)\n}","preventionTips":["Retry transient query failures with backoff; treat 404 as permanent.","Check token namespace vs volume namespace before querying.","Re-list to refresh IDs if a 404 arrives."],"tags":["nomad-api","csi","acl","network"],"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"}