{"record":{"id":"e42df093df6bc453","repo":"hashicorp/nomad","slug":"error-querying-volumes-w","errorCode":null,"errorMessage":"error querying volumes: %w","messagePattern":"error querying volumes: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/volume_status_host.go","lineNumber":89,"sourceCode":"\t\treturn nil // empty is not an error\n\t}\n\n\tstr, err := formatHostVolumes(vols, opts)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error formatting host volumes: %w\", err)\n\t}\n\tc.Ui.Output(c.Colorize().Color(str))\n\treturn nil\n}\n\nfunc getHostVolumeByPrefix(client *api.Client, prefix, ns string) (*api.HostVolumeStub, []*api.HostVolumeStub, error) {\n\tvols, _, err := client.HostVolumes().List(nil, &api.QueryOptions{\n\t\tPrefix:    prefix,\n\t\tNamespace: ns,\n\t})\n\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error querying volumes: %w\", err)\n\t}\n\tswitch len(vols) {\n\tcase 0:\n\t\treturn nil, nil, fmt.Errorf(\"no volumes with prefix or ID %q found\", prefix)\n\tcase 1:\n\t\treturn vols[0], nil, nil\n\tdefault:\n\t\t// search for exact matches to account for multiple exact ID or name\n\t\t// matches across namespaces\n\t\tvar match *api.HostVolumeStub\n\t\texactMatchesCount := 0\n\t\tfor _, vol := range vols {\n\t\t\tif vol.ID == prefix || vol.Name == prefix {\n\t\t\t\texactMatchesCount++\n\t\t\t\tmatch = vol\n\t\t\t}\n\t\t}\n\t\tif exactMatchesCount == 1 {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_status_host.go#L71-L107","documentation":"getHostVolumeByPrefix wraps any error from client.HostVolumes().List issued with a prefix/namespace QueryOptions; the prefix lookup cannot proceed, affecting create/delete/register/status subcommands.","triggerScenarios":"Thrown at command/volume_status_host.go:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check connectivity and ACL capabilities for volume listing","Verify the namespace and prefix query options","Retry transient server errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}