{"record":{"id":"4948ee3f430b13a4","repo":"hashicorp/nomad","slug":"a-template-must-be-supplied-using-template-when-4948ee","errorCode":null,"errorMessage":"A template must be supplied using '-template' when using go-template formatting","messagePattern":"A template must be supplied using '-template' when using go-template formatting","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/var_list.go","lineNumber":299,"sourceCode":"\t// variable paths.\n\tpList := make([]string, len(vars))\n\tfor i, sv := range vars {\n\t\tpList[i] = toPathStr(sv)\n\t}\n\n\treturn pList\n}\n\nfunc (c *VarListCommand) validateOutputFlag() error {\n\tif c.outFmt != \"go-template\" && c.tmpl != \"\" {\n\t\treturn errors.New(errUnexpectedTemplate)\n\t}\n\tswitch c.outFmt {\n\tcase \"json\", \"terse\", \"table\":\n\t\treturn nil\n\tcase \"go-template\":\n\t\tif c.tmpl == \"\" {\n\t\t\treturn errors.New(errMissingTemplate)\n\t\t}\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(errInvalidListOutFormat)\n\t}\n}\n","sourceCodeStart":281,"sourceCodeEnd":306,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/var_list.go#L281-L306","documentation":"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).","triggerScenarios":"Running `vault kv list -output=go-template <path>` with no -template flag (c.tmpl == \"\").","commonSituations":"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.","solutions":["Supply -template with a valid Go template for list entries","Or switch -output to json/terse/table"],"exampleFix":"// before\nvault kv list -output=go-template secret/\n// after\nvault kv list -output=go-template -template='{{ range . }}{{ . }}\\n{{ end }}' secret/","handlingStrategy":"validation","validationCode":"if outFmt == \"go-template\" && tmpl == \"\" {\n\treturn errors.New(\"-output=go-template requires -template\")\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.validateOutputFlag(); err != nil {\n\tif strings.Contains(err.Error(), \"template must be supplied\") {\n\t\t// supply a template or fall back to table output\n\t}\n\treturn err\n}","preventionTips":["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"],"tags":["go","cli","flags","validation"],"backgroundTag":"missing-required-flag","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"}