{"record":{"id":"82241767828a0e08","repo":"hashicorp/nomad","slug":"prefix-matched-multiple-host-volumes-s","errorCode":null,"errorMessage":"Prefix matched multiple host volumes\n\n%s","messagePattern":"Prefix matched multiple host volumes\n\n(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"command/volume_status_host.go","lineNumber":41,"sourceCode":"\t\treturn c.hostVolumeList(client, nodeID, nodePool, opts)\n\t}\n\tif nodeID != \"\" || nodePool != \"\" {\n\t\treturn errors.New(\"-node or -node-pool options can only be used when no ID is provided\")\n\t}\n\n\t// get a host volume that matches the given prefix or a list of all matches\n\t// if an exact match is not found. note we can't use the shared getByPrefix\n\t// helper here because the List API doesn't match the required signature\n\tvolStub, possible, err := getHostVolumeByPrefix(client, id, c.namespace)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%w: %w\", hostVolumeListError, err)\n\t}\n\tif len(possible) > 0 {\n\t\tout, err := formatHostVolumes(possible, opts)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error formatting: %w\", err)\n\t\t}\n\t\treturn fmt.Errorf(\"Prefix matched multiple host volumes\\n\\n%s\", out)\n\t}\n\n\tvol, _, err := client.HostVolumes().Get(volStub.ID, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error querying host volume: %w\", err)\n\t}\n\n\tstr, err := formatHostVolume(vol, opts)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error formatting host volume: %w\", err)\n\t}\n\tc.Ui.Output(c.Colorize().Color(str))\n\treturn nil\n}\n\nfunc (c *VolumeStatusCommand) hostVolumeList(client *api.Client, nodeID, nodePool string, opts formatOpts) error {\n\tif !(opts.json || len(opts.template) > 0) {\n\t\tc.Ui.Output(c.Colorize().Color(\"[bold]Dynamic Host Volumes[reset]\"))","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_status_host.go#L23-L59","documentation":"When a host volume ID prefix matches more than one volume, hostVolumeStatus returns this error whose message embeds the formatted table of candidate matches. It is an intentional disambiguation aid, not an unexpected failure — the CLI displays the choices so the user can re-run with an exact ID.","triggerScenarios":"Run -> hostVolumeStatus with an id argument that getHostVolumeByPrefix resolves to len(possible) > 0 candidates (no exact match, multiple prefix matches).","commonSituations":"Typing a shorthand like 'data' when both 'data-0' and 'data-1' exist; scripted automation assuming a unique prefix that became ambiguous after new volumes were registered.","solutions":["Re-run with the full volume ID from the printed match table","Use a longer prefix unique to the intended volume","In scripts, first list host volumes and assert exactly one match before invoking status"],"exampleFix":"// before\nnomad volume status host data\n// Error: Prefix matched multiple host volumes\n// after\nnomad volume status host data-1","handlingStrategy":"validation","validationCode":"matches := listHostVolumesByIDPrefix(prefix)\nif len(matches) > 1 { /* resolve ambiguity before calling status: pick exact ID */ }\nif len(matches) == 0 { /* handle not-found */ }","typeGuard":"func uniquePrefixMatch(stubs []api.HostVolumeStub, prefix string) (*api.HostVolumeStub, bool) {\n    var hits []*api.HostVolumeStub\n    for i := range stubs { if strings.HasPrefix(stubs[i].ID, prefix) { hits = append(hits, &stubs[i]) } }\n    if len(hits) == 1 { return hits[0], true }\n    return nil, false\n}","tryCatchPattern":"out, err := cmd.CombinedOutput()\nif err != nil && strings.Contains(string(out), \"Prefix matched multiple host volumes\") {\n    // parse the table and re-run with an exact ID\n}","preventionTips":["Use full volume IDs in automation, never bare prefixes","Check for existing volumes before registering similarly-named ones","Detect the 'Prefix matched multiple' message and auto-disambiguate in scripts"],"tags":["cli","ambiguity","host-volumes","prefix-match"],"backgroundTag":"ambiguous-resource-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"}