{"record":{"id":"08474b36ceda156b","repo":"hashicorp/nomad","slug":"a-template-must-be-supplied-using-template-when","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_get.go","lineNumber":210,"sourceCode":"\t\t},\n\t\tOpenURL: openURL,\n\t})\n\tif hint != \"\" {\n\t\tc.Ui.Warn(hint)\n\t}\n\treturn 0\n}\n\nfunc (c *VarGetCommand) validateOutputFlag() error {\n\tif c.outFmt != \"go-template\" && c.tmpl != \"\" {\n\t\treturn errors.New(errUnexpectedTemplate)\n\t}\n\tswitch c.outFmt {\n\tcase \"hcl\", \"json\", \"none\", \"table\":\n\t\treturn nil\n\tcase \"go-template\": //noop - needs more validation\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(errInvalidOutFormat)\n\t}\n}\n\nfunc (c *VarGetCommand) GetConcurrentUI() cli.ConcurrentUi {\n\treturn cli.ConcurrentUi{Ui: c.Ui}\n}\n","sourceCodeStart":192,"sourceCodeEnd":221,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/var_get.go#L192-L221","documentation":"VarGetCommand.validateOutputFlag requires -template when -output=go-template, because go-template rendering has nothing to render without one. This error is returned before any server request is made.","triggerScenarios":"Running `vault kv get -output=go-template <path>` without supplying -template (c.outFmt == \"go-template\" and c.tmpl == \"\").","commonSituations":"Setting the output format in config or a script but forgetting the template argument; aliasing `vault kv get -o go-template` assuming a default template exists.","solutions":["Add a -template flag with a valid Go template, e.g. -template='{{ .Data.data }}'","Or switch -output to a format that needs no template (table, json, hcl, none)"],"exampleFix":"// before\nvault kv get -output=go-template secret/foo\n// after\nvault kv get -output=go-template -template='{{ .Data.data.foo }}' secret/foo","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// prompt user for -template or fall back to table output\n\t}\n\treturn err\n}","preventionTips":["When setting -output=go-template, always pair it with -template in the same command/profile","Default to table output in scripts to avoid template requirements","Keep go-template invocations in wrapper functions that enforce the template argument"],"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-08T15:18:49.778Z"}