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, nil

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Provide at least the first two characters of the node ID.
  2. Run `nomad node status` with no argument to list all nodes and copy a full/prefix ID.
  3. 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

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


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