{"record":{"id":"899b9005d812e93e","repo":"hashicorp/nomad","slug":"identifier-must-contain-at-least-two-characters","errorCode":null,"errorMessage":"Identifier must contain at least two characters.","messagePattern":"Identifier must contain at least two characters\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/deployment_status.go","lineNumber":534,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t}\n}\n\nfunc getDeployment(client *api.Deployments, dID string) (match *api.Deployment, possible []*api.Deployment, err error) {\n\t// First attempt an immediate lookup if we have a proper length\n\tif len(dID) == 36 {\n\t\td, _, err := client.Info(dID, nil)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\n\t\treturn d, nil, nil\n\t}\n\n\tdID = strings.ReplaceAll(dID, \"-\", \"\")\n\tif len(dID) == 1 {\n\t\treturn nil, nil, fmt.Errorf(\"Identifier must contain at least two characters.\")\n\t}\n\tif len(dID)%2 == 1 {\n\t\t// Identifiers must be of even length, so we strip off the last byte\n\t\t// to provide a consistent user experience.\n\t\tdID = dID[:len(dID)-1]\n\t}\n\n\t// Have to do a prefix lookup\n\tdeploys, _, err := client.PrefixList(dID)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tswitch len(deploys) {\n\tcase 0:\n\t\treturn nil, nil, fmt.Errorf(\"Deployment ID %q matched no deployments\", dID)\n\tcase 1:\n\t\treturn deploys[0], nil, nil","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/deployment_status.go#L516-L552","documentation":"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.","triggerScenarios":"Running a deployment status command with a 1-character (after dash removal) prefix, e.g. `nomad deployment status a`.","commonSituations":"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).","solutions":["Provide at least two characters of the deployment ID prefix","Use the full 36-character UUID from `nomad deployment list`","Fix the script variable so it isn't truncated to one character"],"exampleFix":"// before\nnomad deployment status a\n// after\nnomad deployment status ab   # or the full UUID","handlingStrategy":"validation","validationCode":"trimmed := strings.ReplaceAll(id, \"-\", \"\")\nif len(trimmed) < 2 {\n    return fmt.Errorf(\"deployment ID prefix must be at least 2 characters\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always paste the full UUID from `nomad deployment list`","Guard scripted prefixes to require >= 2 hex chars","Validate ID non-emptiness after shell trimming"],"tags":["cli","identifier","argument-validation"],"backgroundTag":"invalid-identifier-prefix","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"}