hashicorp/nomad · error
A template must be supplied using '-template' when using go-
Error message
A template must be supplied using '-template' when using go-template formatting
What it means
Flag validation error in VarListCommand.validateOutputFlag: when -out go-template is selected, a Go template must also be given via -template; it fires when outFmt is go-template but tmpl is empty (errMissingTemplate).
Source
Thrown at command/var_list.go:299
// variable paths.
pList := make([]string, len(vars))
for i, sv := range vars {
pList[i] = toPathStr(sv)
}
return pList
}
func (c *VarListCommand) validateOutputFlag() error {
if c.outFmt != "go-template" && c.tmpl != "" {
return errors.New(errUnexpectedTemplate)
}
switch c.outFmt {
case "json", "terse", "table":
return nil
case "go-template":
if c.tmpl == "" {
return errors.New(errMissingTemplate)
}
return nil
default:
return errors.New(errInvalidListOutFormat)
}
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Supply -template with a valid Go template for list entries
- Or switch -output to json/terse/table
Example fix
// before
vault kv list -output=go-template secret/
// after
vault kv list -output=go-template -template='{{ range . }}{{ . }}\n{{ end }}' secret/ Defensive patterns
Strategy: validation
Validate before calling
if outFmt == "go-template" && tmpl == "" {
return errors.New("-output=go-template requires -template")
} Try / catch
if err := cmd.validateOutputFlag(); err != nil {
if strings.Contains(err.Error(), "template must be supplied") {
// supply a template or fall back to table output
}
return err
} Prevention
- Never set -output=go-template in profiles without a default template
- Wrap go-template usage in helper scripts that take the template as a required argument
- Prefer terse/json in automation
When it happens
Trigger: Running `vault kv list -output=go-template <path>` with no -template flag (c.tmpl == "").
Common situations: Setting -output=go-template in a config/profile while the template is supplied in a different invocation; forgetting the flag when converting from table output.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- The '-template' flag is only valid when using 'go-template'
- A template must be supplied using '-template' when using go-
- Invalid value for "-out"; valid values are [go-template, hcl
- The '-template' flag is only valid when using 'go-template'
- Invalid value for "-out"; valid values are [go-template, jso
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/4948ee3f430b13a4.
Report an issue: GitHub.