{"record":{"id":"bf6e9de44feb5bab","repo":"hashicorp/nomad","slug":"error-listing-csi-volumes-w","errorCode":null,"errorMessage":"Error listing CSI volumes: %w","messagePattern":"Error listing CSI volumes: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/volume_status_csi.go","lineNumber":32,"sourceCode":"\tmultierror \"github.com/hashicorp/go-multierror\"\n\t\"github.com/hashicorp/nomad/api\"\n)\n\nfunc (c *VolumeStatusCommand) csiVolumeStatus(client *api.Client, id string, opts formatOpts) error {\n\tif id == \"\" {\n\t\treturn c.csiVolumesList(client, opts)\n\t}\n\n\t// get a CSI volume that matches the given prefix or a list of all matches if an\n\t// exact match is not found.\n\tvolStub, possible, err := getByPrefix[api.CSIVolumeListStub](\"volumes\", client.CSIVolumes().List,\n\t\tfunc(vol *api.CSIVolumeListStub, prefix string) bool { return vol.ID == prefix },\n\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)","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_status_csi.go#L14-L50","documentation":"csiVolumeStatus first lists CSI volumes with a prefix search (client.CSIVolumes().List with Prefix). If the API list call returns an error (network failure, ACL denial, server error), it is wrapped as `Error listing CSI volumes`. This is a transport/API-level failure, not a parsing problem.","triggerScenarios":"`nomad volume status <prefix>` when the Nomad API call for listing CSI volumes fails: unreachable agent, expired/insufficient ACL token lacking volume read (e.g. `volume` namespace capabilities), server-side 5xx.","commonSituations":"Wrong NOMAD_ADDR; ACL token without volume listing permissions; CSI plugin not running so the server errors; network partition between CLI and cluster.","solutions":["Inspect the wrapped cause (%w output) — fix connectivity (NOMAD_ADDR, agent health) or re-authenticate the ACL token.","Verify the token has list/read capabilities on volumes in the target namespace: `nomad acl token self`.","Check `nomad server members` / agent logs for server-side errors and retry once the cluster is healthy."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-checks before calling\nif os.Getenv(\"NOMAD_TOKEN\") == \"\" && aclEnabled { return fmt.Errorf(\"NOMAD_TOKEN required\") }\nif _, err := net.DialTimeout(\"tcp\", agentAddr, 2*time.Second); err != nil {\n\treturn fmt.Errorf(\"nomad agent unreachable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"vols, err := client.CSIVolumes().List(q)\nif err != nil {\n\tvar apiErr *api.APIError\n\tif errors.As(err, &apiErr) && apiErr.ErrCode() == 403 {\n\t\treturn fmt.Errorf(\"token lacks volume list capability: %v\", err)\n\t}\n\treturn fmt.Errorf(\"Error listing CSI volumes: %w\", err)\n}","preventionTips":["Verify NOMAD_ADDR and agent health before scripting volume commands.","Grant tokens the volume list/read capabilities for the right namespace.","Use %w wrapping so the root cause is visible; always print it when debugging."],"tags":["nomad-api","csi","network","acl"],"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"}