hashicorp/nomad · error

Error querying host volume: %w

Error message

Error querying host volume: %w

What it means

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.

Source

Thrown at command/volume_status_host.go:46

	// get a host volume that matches the given prefix or a list of all matches
	// if an exact match is not found. note we can't use the shared getByPrefix
	// helper here because the List API doesn't match the required signature
	volStub, possible, err := getHostVolumeByPrefix(client, id, c.namespace)
	if err != nil {
		return fmt.Errorf("%w: %w", hostVolumeListError, err)
	}
	if len(possible) > 0 {
		out, err := formatHostVolumes(possible, opts)
		if err != nil {
			return fmt.Errorf("Error formatting: %w", err)
		}
		return fmt.Errorf("Prefix matched multiple host volumes\n\n%s", out)
	}

	vol, _, err := client.HostVolumes().Get(volStub.ID, nil)
	if err != nil {
		return fmt.Errorf("Error querying host volume: %w", err)
	}

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

func (c *VolumeStatusCommand) hostVolumeList(client *api.Client, nodeID, nodePool string, opts formatOpts) error {
	if !(opts.json || len(opts.template) > 0) {
		c.Ui.Output(c.Colorize().Color("[bold]Dynamic Host Volumes[reset]"))
	}

	vols, _, err := client.HostVolumes().List(&api.HostVolumeListRequest{
		NodeID:   nodeID,
		NodePool: nodePool,

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Read the wrapped error: 404 -> re-list to confirm the volume still exists; 403 -> fix ACL token/namespace
  2. Retry the command; the failure may be transient between the List and Get calls
  3. Verify NOMAD_NAMESPACE and token permissions cover the target volume

Example fix

// before
nomad volume status host vol-abc  # 403
// after
export NOMAD_TOKEN=<token-with-host-volume-read>
export NOMAD_NAMESPACE=default
nomad volume status host vol-abc
Defensive patterns

Strategy: retry

Validate before calling

// verify the volume still exists right before Get
stubs, _, err := client.HostVolumes().List(nil)
if err != nil || !containsID(stubs, id) { /* abort or re-resolve */ }

Try / catch

if err := cmd.Run(); err != nil {
    if strings.Contains(err.Error(), "Error querying host volume") {
        if strings.Contains(err.Error(), "404") { /* re-list: volume vanished */ } else if strings.Contains(err.Error(), "403") { /* fix ACL/namespace */ }
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: Race where the volume was deregistered moments before; token scoped to a different namespace; transient server unavailability during the two-step lookup.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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