hashicorp/nomad · warning

Prefix matched multiple host volumes %s

Error message

Prefix matched multiple host volumes

%s

What it means

When a host volume ID prefix matches more than one volume, hostVolumeStatus returns this error whose message embeds the formatted table of candidate matches. It is an intentional disambiguation aid, not an unexpected failure — the CLI displays the choices so the user can re-run with an exact ID.

Source

Thrown at command/volume_status_host.go:41

		return c.hostVolumeList(client, nodeID, nodePool, opts)
	}
	if nodeID != "" || nodePool != "" {
		return errors.New("-node or -node-pool options can only be used when no ID is provided")
	}

	// 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]"))

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Re-run with the full volume ID from the printed match table
  2. Use a longer prefix unique to the intended volume
  3. In scripts, first list host volumes and assert exactly one match before invoking status

Example fix

// before
nomad volume status host data
// Error: Prefix matched multiple host volumes
// after
nomad volume status host data-1
Defensive patterns

Strategy: validation

Validate before calling

matches := listHostVolumesByIDPrefix(prefix)
if len(matches) > 1 { /* resolve ambiguity before calling status: pick exact ID */ }
if len(matches) == 0 { /* handle not-found */ }

Type guard

func uniquePrefixMatch(stubs []api.HostVolumeStub, prefix string) (*api.HostVolumeStub, bool) {
    var hits []*api.HostVolumeStub
    for i := range stubs { if strings.HasPrefix(stubs[i].ID, prefix) { hits = append(hits, &stubs[i]) } }
    if len(hits) == 1 { return hits[0], true }
    return nil, false
}

Try / catch

out, err := cmd.CombinedOutput()
if err != nil && strings.Contains(string(out), "Prefix matched multiple host volumes") {
    // parse the table and re-run with an exact ID
}

Prevention

When it happens

Trigger: Run -> hostVolumeStatus with an id argument that getHostVolumeByPrefix resolves to len(possible) > 0 candidates (no exact match, multiple prefix matches).

Common situations: Typing a shorthand like 'data' when both 'data-0' and 'data-1' exist; scripted automation assuming a unique prefix that became ambiguous after new volumes were registered.

Related errors


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