{"record":{"id":"0dd6f775b25a804c","repo":"hashicorp/nomad","slug":"prefix-matched-multiple-nodes-n-n-s","errorCode":null,"errorMessage":"Prefix matched multiple nodes\\n\\n%s","messagePattern":"Prefix matched multiple nodes\\\\n\\\\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/node.go","lineNumber":94,"sourceCode":"// lookupNodeID looks up a nodeID prefix and returns the full ID or an error.\n// The error will always be suitable for displaying to users.\nfunc lookupNodeID(client *api.Nodes, nodeID string) (string, error) {\n\tif len(nodeID) == 1 {\n\t\treturn \"\", fmt.Errorf(\"Node ID must contain at least two characters.\")\n\t}\n\n\tnodeID = sanitizeUUIDPrefix(nodeID)\n\tnodes, _, err := client.PrefixList(nodeID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Error querying node: %w\", err)\n\t}\n\n\tif len(nodes) == 0 {\n\t\treturn \"\", fmt.Errorf(\"No node(s) with prefix or id %q found\", nodeID)\n\t}\n\n\tif len(nodes) > 1 {\n\t\treturn \"\", fmt.Errorf(\"Prefix matched multiple nodes\\n\\n%s\",\n\t\t\tformatNodeStubList(nodes, true))\n\t}\n\n\treturn nodes[0].ID, nil\n}\n","sourceCodeStart":76,"sourceCodeEnd":100,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/node.go#L76-L100","documentation":"If PrefixList returns more than one node for the given prefix and none exactly equals the input, lookupNodeID refuses to guess and returns \"Prefix matched multiple nodes\" followed by a formatted table of candidate node stubs (formatted via formatNodeStubList). It asks the user to supply a longer prefix.","triggerScenarios":"Calling `nomad node status <prefix>` where the prefix matches 2+ node IDs and the input is not itself an exact node ID.","commonSituations":"Very short prefixes in homogeneous clusters (nodes provisioned by the same tooling share ID prefixes); copy-pasting only a few ID characters; scripted ID selection that truncates IDs too aggressively.","solutions":["Extend the prefix using characters from the candidate list printed with the error.","Use the full 36-character node UUID to be unambiguous.","In scripts, pick IDs programmatically (e.g. from `nomad node status -json` filtered by name/datacenter) instead of short prefixes.","Add `-node-class` or filter by datacenter if your tooling supports it."],"exampleFix":"// before (shell)\nnomad node status a1    # ambiguous\n// after\nnomad node status a1b2c3d4-5678-90ab-cdef-1234567890ab","handlingStrategy":"validation","validationCode":"// shell: require a long, unambiguous prefix\n[ ${#NODE_ID} -ge 8 ] || { echo \"use at least 8 chars of the node UUID\"; exit 1; }\nnomad node status \"$NODE_ID\"","typeGuard":null,"tryCatchPattern":"// bash: use the candidate list in the error to disambiguate\nif ! out=$(nomad node status \"$ID\" 2>&1); then\n  case \"$out\" in *\"matched multiple nodes\"*) echo \"$out\" ;; esac\nfi","preventionTips":["Use full 36-char UUIDs in scripts andCI.","Raise minimum prefix length in tooling when clusters have similar node IDs.","Filter nodes by name/class/datacenter via `nomad node status -json` + jq instead of prefixes."],"tags":["cli","nomad","node","ambiguity"],"backgroundTag":"ambiguous-identifier","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"}