{"record":{"id":"1a9d5b17d514e438","repo":"GoogleContainerTools/skaffold","slug":"setting-template-flag-w-1a9d5b","errorCode":null,"errorMessage":"setting template flag: %w","messagePattern":"setting template flag: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/skaffold/app/flags/template.go","lineNumber":51,"sourceCode":"\nfunc (t *TemplateFlag) String() string {\n\treturn t.rawTemplate\n}\n\nfunc (t *TemplateFlag) Usage() string {\n\tdefaultUsage := \"Format output with go-template.\"\n\tif t.context != nil {\n\t\tgoType := reflect.TypeOf(t.context)\n\t\turl := fmt.Sprintf(\"https://godoc.org/%s#%s\", goType.PkgPath(), goType.Name())\n\t\tdefaultUsage += fmt.Sprintf(\" For full struct documentation, see %s\", url)\n\t}\n\treturn defaultUsage\n}\n\nfunc (t *TemplateFlag) Set(value string) error {\n\ttmpl, err := parseTemplate(value)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"setting template flag: %w\", err)\n\t}\n\tt.rawTemplate = value\n\tt.template = tmpl\n\treturn nil\n}\n\nfunc (t *TemplateFlag) Type() string {\n\treturn fmt.Sprintf(\"%T\", t)\n}\n\nfunc (t *TemplateFlag) Template() *template.Template {\n\treturn t.template\n}\n\nfunc NewTemplateFlag(value string, context interface{}) *TemplateFlag {\n\treturn &TemplateFlag{\n\t\ttemplate:    template.Must(parseTemplate(value)),\n\t\trawTemplate: value,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/cmd/skaffold/app/flags/template.go#L33-L69","documentation":"TemplateFlag.Set parses the value of the `--default-repo`/output template flags with parseTemplate. If the string is not a valid Go text/template (bad syntax, unclosed actions), the parse error is wrapped as `setting template flag: ...` at flag-parse time, before skaffold does any work.","triggerScenarios":"Passing a template flag value with invalid Go template syntax, e.g. `--default-repo '{{.REPO'` (unclosed `{{`), or illegal template constructs; verified by TestTemplateSet.","commonSituations":"Shell interpolation eating the closing braces; copying templates with unsupported template functions; quoting mistakes so the value contains stray braces.","solutions":["Fix the template syntax; ensure every `{{` has a matching `}}` (e.g. `{{.IMAGE_NAME}}`).","Single-quote the flag value in shells to prevent brace/variable expansion.","Test the template in isolation with a small Go template or by echoing the intended output."],"exampleFix":"// before\nskaffold run --default-repo '{{.REPO'\n// after\nskaffold run --default-repo 'gcr.io/my-project'","handlingStrategy":"validation","validationCode":"if strings.Count(tpl, \"{{\") != strings.Count(tpl, \"}}\") {\n    return fmt.Errorf(\"unbalanced template braces in %q\", tpl)\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil {\n    if strings.Contains(err.Error(), \"setting template flag\") {\n        // fix template syntax and re-run\n    }\n}","preventionTips":["Single-quote template values in shell to prevent brace/variable expansion.","Use only documented template fields (e.g. {{.IMAGE_NAME}}).","Validate Go template syntax locally before using it in CI."],"tags":["cli","template","go-template","skaffold"],"backgroundTag":"invalid-template-syntax","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}