{"record":{"id":"f359e3acd1b28d1c","repo":"hashicorp/nomad","slug":"node-or-node-pool-options-can-only-be-used-when","errorCode":null,"errorMessage":"-node or -node-pool options can only be used when no ID is provided","messagePattern":"-node or -node-pool options can only be used when no ID is provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/volume_status_host.go","lineNumber":26,"sourceCode":"\t\"fmt\"\n\t\"sort\"\n\t\"strings\"\n\n\thumanize \"github.com/dustin/go-humanize\"\n\t\"github.com/hashicorp/nomad/api\"\n)\n\n// hostVolumeListError is a non-fatal error for the 'volume status' command when\n// used with the -type option unset, because we want to continue on to list CSI\n// volumes\nvar hostVolumeListError = errors.New(\"Error listing host volumes\")\n\nfunc (c *VolumeStatusCommand) hostVolumeStatus(client *api.Client, id, nodeID, nodePool string, opts formatOpts) error {\n\tif id == \"\" {\n\t\treturn c.hostVolumeList(client, nodeID, nodePool, opts)\n\t}\n\tif nodeID != \"\" || nodePool != \"\" {\n\t\treturn errors.New(\"-node or -node-pool options can only be used when no ID is provided\")\n\t}\n\n\t// get a host volume that matches the given prefix or a list of all matches\n\t// if an exact match is not found. note we can't use the shared getByPrefix\n\t// helper here because the List API doesn't match the required signature\n\tvolStub, possible, err := getHostVolumeByPrefix(client, id, c.namespace)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%w: %w\", hostVolumeListError, err)\n\t}\n\tif len(possible) > 0 {\n\t\tout, err := formatHostVolumes(possible, opts)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error formatting: %w\", err)\n\t\t}\n\t\treturn fmt.Errorf(\"Prefix matched multiple host volumes\\n\\n%s\", out)\n\t}\n\n\tvol, _, err := client.HostVolumes().Get(volStub.ID, nil)","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_status_host.go#L8-L44","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove -node/-node-pool when passing a volume ID: `nomad volume status <id>`","Keep -node/-node-pool only for the list form with no ID: `nomad volume status -node <node>`","Update the calling script to make ID and node/pool filters mutually exclusive"],"exampleFix":"// before\nnomad volume status my-vol -node node-1\n// after\nnomad volume status my-vol\n// or, to filter the list:\nnomad volume status -node node-1","handlingStrategy":"validation","validationCode":"if id != \"\" && (node != \"\" || nodePool != \"\") {\n    return fmt.Errorf(\"-node/-node-pool cannot be combined with a volume ID\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat ID lookup and node/pool listing as mutually exclusive in scripts","Read `nomad volume status -help` before combining filters","Add argument checks in wrapper scripts around nomad commands"],"tags":["nomad","cli","flag-conflict","usage"],"backgroundTag":"mutually-exclusive-flags","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"}