hashicorp/nomad · error

Identifier must contain at least two characters.

Error message

Identifier must contain at least two characters.

What it means

getDeployment in deployment_status.go interprets its argument as a (possibly truncated) deployment ID. It strips dashes and requires at least two hex characters, because the matching logic works on UUID prefixes and a single character is too ambiguous/short to resolve.

Source

Thrown at command/deployment_status.go:534

			continue
		}
	}
}

func getDeployment(client *api.Deployments, dID string) (match *api.Deployment, possible []*api.Deployment, err error) {
	// First attempt an immediate lookup if we have a proper length
	if len(dID) == 36 {
		d, _, err := client.Info(dID, nil)
		if err != nil {
			return nil, nil, err
		}

		return d, nil, nil
	}

	dID = strings.ReplaceAll(dID, "-", "")
	if len(dID) == 1 {
		return nil, nil, fmt.Errorf("Identifier must contain at least two characters.")
	}
	if len(dID)%2 == 1 {
		// Identifiers must be of even length, so we strip off the last byte
		// to provide a consistent user experience.
		dID = dID[:len(dID)-1]
	}

	// Have to do a prefix lookup
	deploys, _, err := client.PrefixList(dID)
	if err != nil {
		return nil, nil, err
	}

	switch len(deploys) {
	case 0:
		return nil, nil, fmt.Errorf("Deployment ID %q matched no deployments", dID)
	case 1:
		return deploys[0], nil, nil

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Provide at least two characters of the deployment ID prefix
  2. Use the full 36-character UUID from `nomad deployment list`
  3. Fix the script variable so it isn't truncated to one character

Example fix

// before
nomad deployment status a
// after
nomad deployment status ab   # or the full UUID
Defensive patterns

Strategy: validation

Validate before calling

trimmed := strings.ReplaceAll(id, "-", "")
if len(trimmed) < 2 {
    return fmt.Errorf("deployment ID prefix must be at least 2 characters")
}

Prevention

When it happens

Trigger: Running a deployment status command with a 1-character (after dash removal) prefix, e.g. `nomad deployment status a`.

Common situations: Typing an ID prefix that is too short; scripting with a variable that ended up mostly empty (e.g. only one hex char survived shell trimming).

Related errors


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