{"record":{"id":"fae5d2f3721083f2","repo":"hashicorp/nomad","slug":"node-id-must-contain-at-least-two-characters","errorCode":null,"errorMessage":"Node ID must contain at least two characters.","messagePattern":"Node ID must contain at least two characters\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/node.go","lineNumber":80,"sourceCode":"\t\tkeys = append(keys, k)\n\t}\n\tsort.Strings(keys)\n\n\tvar rows []string\n\tfor _, k := range keys {\n\t\tif k != \"\" {\n\t\t\trows = append(rows, fmt.Sprintf(\"%s|%s\", k, meta[k]))\n\t\t}\n\t}\n\n\treturn formatKV(rows)\n}\n\n// 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","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/node.go#L62-L98","documentation":"lookupNodeID resolves a user-supplied node ID prefix to a full node ID via the Nodes.PrefixList API. Nomad requires prefix searches to be at least two characters long (after sanitization), so a single-character node ID is rejected up front with this message rather than issuing a doomed API call.","triggerScenarios":"Calling `nomad node status <id>` (or any Run path that invokes lookupNodeID) with a node ID argument of exactly one character, e.g. `nomad node status a`.","commonSituations":"User copied only part of a node ID; shell scripts truncate IDs; ambiguous short prefixes typed by hand in interactive sessions.","solutions":["Provide at least the first two characters of the node ID.","Run `nomad node status` with no argument to list all nodes and copy a full/prefix ID.","In scripts, ensure the ID variable is not truncated to a single character."],"exampleFix":"// before (shell)\nnomad node status a\n// after\nnomad node status a1b2c3d4","handlingStrategy":"validation","validationCode":"// shell: enforce minimum prefix length\n[ ${#NODE_ID} -ge 2 ] || { echo \"node id too short: '$NODE_ID'\"; exit 1; }\nnomad node status \"$NODE_ID\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always copy full node UUIDs from `nomad node status` output.","In scripts, assert prefix length >= 2 before invoking commands.","Avoid hand-truncating IDs from memory or logs."],"tags":["cli","nomad","node","input-validation"],"backgroundTag":"invalid-argument-length","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"}