{"record":{"id":"9482fd211a5028e9","repo":"hashicorp/nomad","slug":"error-formatting-w-9482fd","errorCode":null,"errorMessage":"Error formatting: %w","messagePattern":"Error formatting: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/volume_status_host.go","lineNumber":39,"sourceCode":"func (c *VolumeStatusCommand) hostVolumeStatus(client *api.Client, id, nodeID, nodePool string, opts formatOpts) error {\n\tif id == \"\" {\n\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 {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_status_host.go#L21-L57","documentation":"hostVolumeStatus wraps failures from formatHostVolumes when the ID prefix matched multiple host volumes and they must be rendered as a list to help the user disambiguate. Rendering (JSON/template/table) failed; the wrapped cause explains why.","triggerScenarios":"getHostVolumeByPrefix returns len(possible) > 0 (ambiguous prefix) and formatHostVolumes(possible, opts) fails because of an invalid -template, -json+ -template combination, or template field mismatch on the stub list.","commonSituations":"User supplies a short prefix like 'web' matching several volumes, plus a malformed -template intended to filter the matches; error compounds the ambiguity message path.","solutions":["Fix the -template syntax/fields used with the multi-match listing","Use a longer, unambiguous prefix so the code takes the single-volume path instead","Run without -template to see the plain match table and pick the exact ID"],"exampleFix":"// before\nnomad volume status -template '{{.IDbad}}' host web\n// after\nnomad volume status host web-prod-1","handlingStrategy":"validation","validationCode":"if opts.template != \"\" { if _, err := template.New(\"t\").Parse(opts.template); err != nil { return err } }","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil {\n    if strings.Contains(err.Error(), \"Error formatting\") { /* ambiguous prefix path: drop -template or fix it */ }\n}","preventionTips":["Validate templates before CLI invocation","Prefer unambiguous full IDs in scripts","Run plain listing first when a prefix may match multiple"],"tags":["cli","formatting","template","host-volumes"],"backgroundTag":"template-render-failed","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"}