hashicorp/nomad · error
Node ID must contain at least two characters.
Error message
Node ID must contain at least two characters.
What it means
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.
Source
Thrown at command/node.go:80
keys = append(keys, k)
}
sort.Strings(keys)
var rows []string
for _, k := range keys {
if k != "" {
rows = append(rows, fmt.Sprintf("%s|%s", k, meta[k]))
}
}
return formatKV(rows)
}
// lookupNodeID looks up a nodeID prefix and returns the full ID or an error.
// The error will always be suitable for displaying to users.
func lookupNodeID(client *api.Nodes, nodeID string) (string, error) {
if len(nodeID) == 1 {
return "", fmt.Errorf("Node ID must contain at least two characters.")
}
nodeID = sanitizeUUIDPrefix(nodeID)
nodes, _, err := client.PrefixList(nodeID)
if err != nil {
return "", fmt.Errorf("Error querying node: %w", err)
}
if len(nodes) == 0 {
return "", fmt.Errorf("No node(s) with prefix or id %q found", nodeID)
}
if len(nodes) > 1 {
return "", fmt.Errorf("Prefix matched multiple nodes\n\n%s",
formatNodeStubList(nodes, true))
}
return nodes[0].ID, nilView on GitHub (pinned to 482b49bf1a)
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.
Example fix
// before (shell) nomad node status a // after nomad node status a1b2c3d4
Defensive patterns
Strategy: validation
Validate before calling
// shell: enforce minimum prefix length
[ ${#NODE_ID} -ge 2 ] || { echo "node id too short: '$NODE_ID'"; exit 1; }
nomad node status "$NODE_ID" Prevention
- 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.
When it happens
Trigger: 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`.
Common situations: User copied only part of a node ID; shell scripts truncate IDs; ambiguous short prefixes typed by hand in interactive sessions.
Related errors
- Error querying node: %w
- No node(s) with prefix or id %q found
- Prefix matched multiple nodes\n\n%s
- A template must be supplied using '-template' when using go-
- Invalid value for "-out"; valid values are [go-template, hcl
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/fae5d2f3721083f2.
Report an issue: GitHub.