hashicorp/nomad · error
Error formatting: %w
Error message
Error formatting: %w
What it means
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.
Source
Thrown at command/volume_status_host.go:39
func (c *VolumeStatusCommand) hostVolumeStatus(client *api.Client, id, nodeID, nodePool string, opts formatOpts) error {
if id == "" {
return c.hostVolumeList(client, nodeID, nodePool, opts)
}
if nodeID != "" || nodePool != "" {
return errors.New("-node or -node-pool options can only be used when no ID is provided")
}
// get a host volume that matches the given prefix or a list of all matches
// if an exact match is not found. note we can't use the shared getByPrefix
// helper here because the List API doesn't match the required signature
volStub, possible, err := getHostVolumeByPrefix(client, id, c.namespace)
if err != nil {
return fmt.Errorf("%w: %w", hostVolumeListError, err)
}
if len(possible) > 0 {
out, err := formatHostVolumes(possible, opts)
if err != nil {
return fmt.Errorf("Error formatting: %w", err)
}
return fmt.Errorf("Prefix matched multiple host volumes\n\n%s", out)
}
vol, _, err := client.HostVolumes().Get(volStub.ID, nil)
if err != nil {
return fmt.Errorf("Error querying host volume: %w", err)
}
str, err := formatHostVolume(vol, opts)
if err != nil {
return fmt.Errorf("Error formatting host volume: %w", err)
}
c.Ui.Output(c.Colorize().Color(str))
return nil
}
func (c *VolumeStatusCommand) hostVolumeList(client *api.Client, nodeID, nodePool string, opts formatOpts) error {View on GitHub (pinned to 482b49bf1a)
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
Example fix
// before
nomad volume status -template '{{.IDbad}}' host web
// after
nomad volume status host web-prod-1 Defensive patterns
Strategy: validation
Validate before calling
if opts.template != "" { if _, err := template.New("t").Parse(opts.template); err != nil { return err } } Try / catch
if err := cmd.Run(); err != nil {
if strings.Contains(err.Error(), "Error formatting") { /* ambiguous prefix path: drop -template or fix it */ }
} Prevention
- Validate templates before CLI invocation
- Prefer unambiguous full IDs in scripts
- Run plain listing first when a prefix may match multiple
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Error formatting host volume: %w
- format error: %v
- format error: %w
- Error listing host volumes
- json format does not support template option.
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/9482fd211a5028e9.
Report an issue: GitHub.