hashicorp/nomad · error

error querying volumes

Error message

error querying volumes: %w

What it means

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.

Solutions

  1. Check connectivity and ACL capabilities for volume listing
  2. Verify the namespace and prefix query options
  3. Retry transient server errors
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at command/volume_status_host.go:89 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/e42df093df6bc453. Report an issue: GitHub.

Appendix: source

Thrown at command/volume_status_host.go:89

		return nil // empty is not an error
	}

	str, err := formatHostVolumes(vols, opts)
	if err != nil {
		return fmt.Errorf("Error formatting host volumes: %w", err)
	}
	c.Ui.Output(c.Colorize().Color(str))
	return nil
}

func getHostVolumeByPrefix(client *api.Client, prefix, ns string) (*api.HostVolumeStub, []*api.HostVolumeStub, error) {
	vols, _, err := client.HostVolumes().List(nil, &api.QueryOptions{
		Prefix:    prefix,
		Namespace: ns,
	})

	if err != nil {
		return nil, nil, fmt.Errorf("error querying volumes: %w", err)
	}
	switch len(vols) {
	case 0:
		return nil, nil, fmt.Errorf("no volumes with prefix or ID %q found", prefix)
	case 1:
		return vols[0], nil, nil
	default:
		// search for exact matches to account for multiple exact ID or name
		// matches across namespaces
		var match *api.HostVolumeStub
		exactMatchesCount := 0
		for _, vol := range vols {
			if vol.ID == prefix || vol.Name == prefix {
				exactMatchesCount++
				match = vol
			}
		}
		if exactMatchesCount == 1 {

View on GitHub (pinned to 482b49bf1a)