hashicorp/nomad · error

-node or -node-pool options can only be used when no ID is p

Error message

-node or -node-pool options can only be used when no ID is provided

What it means

The 'volume status' command's hostVolumeStatus rejects combining an explicit volume ID prefix with the -node or -node-pool filters. Those filters only make sense when listing all volumes on a node/pool, not when resolving a single volume by ID, so passing both is treated as a usage error.

Source

Thrown at command/volume_status_host.go:26

	"fmt"
	"sort"
	"strings"

	humanize "github.com/dustin/go-humanize"
	"github.com/hashicorp/nomad/api"
)

// hostVolumeListError is a non-fatal error for the 'volume status' command when
// used with the -type option unset, because we want to continue on to list CSI
// volumes
var hostVolumeListError = errors.New("Error listing host volumes")

func (c *VolumeStatusCommand) hostVolumeStatus(client *api.Client, id, nodeID, nodePool string, opts formatOpts) error {
	if id == "" {
		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)

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Remove -node/-node-pool when passing a volume ID: `nomad volume status <id>`
  2. Keep -node/-node-pool only for the list form with no ID: `nomad volume status -node <node>`
  3. Update the calling script to make ID and node/pool filters mutually exclusive

Example fix

// before
nomad volume status my-vol -node node-1
// after
nomad volume status my-vol
// or, to filter the list:
nomad volume status -node node-1
Defensive patterns

Strategy: validation

Validate before calling

if id != "" && (node != "" || nodePool != "") {
    return fmt.Errorf("-node/-node-pool cannot be combined with a volume ID")
}

Prevention

When it happens

Trigger: Running `nomad volume status <id> -node <node>` or `nomad volume status <id> -node-pool <pool>` — i.e. an ID argument is present AND nodeID or nodePool is non-empty.

Common situations: Users copying a listing command (`-node`) and appending an ID; scripts accumulating flags across subcommands; misunderstanding that -node narrows the ID lookup rather than the list.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


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