{"record":{"id":"7fbbd0865c21b2a4","repo":"GoogleContainerTools/skaffold","slug":"error-parsing-pod-template-w","errorCode":null,"errorMessage":"error parsing pod template: %w","messagePattern":"error parsing pod template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/kubernetes/generator/generate.go","lineNumber":37,"sourceCode":"import (\n\t\"bytes\"\n\t\"fmt\"\n\t\"html/template\"\n)\n\ntype Container struct {\n\tName  string\n\tImage string\n\tPort  int\n}\n\n// Generate generates kubernetes resources for the given image, and returns the generated manifest string\nfunc Generate(name string, port int) ([]byte, *Container, error) {\n\tc := Container{name, name, port}\n\n\tt, err := template.New(\"deployment\").Parse(yamlTemplate)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error parsing pod template: %w\", err)\n\t}\n\n\tvar buf bytes.Buffer\n\tif err = t.Execute(&buf, c); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error executing template: %w\", err)\n\t}\n\n\treturn buf.Bytes(), &c, nil\n}\n","sourceCodeStart":19,"sourceCodeEnd":47,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/kubernetes/generator/generate.go#L19-L47","documentation":"Generate builds a default Kubernetes deployment manifest by parsing the hardcoded yamlTemplate with text/template. This error is returned when template.New(\"deployment\").Parse fails. Because the template is a compile-time constant embedded in the binary, a parse failure is essentially a programming bug or corrupted installation rather than something caused by user input (name/port only fill template variables).","triggerScenarios":"Calling skaffold kubernetes generator Generate(name, port) — or CLI commands like `skaffold dev --port-forward` / the `skaffold kpt`/bootstrap generation path — where the embedded deployment yamlTemplate fails to parse.","commonSituations":"A Skaffold build/install where the generate.go template literal was modified or corrupted; forking Skaffold and editing yamlTemplate with invalid template syntax (unclosed {{ }}, bad actions); go:embed/static string issues after vendoring.","solutions":["Reinstall or rebuild Skaffold from an unmodified source — the template is embedded and a parse failure means corrupted source/binaries","If you modified yamlTemplate, check template syntax: balanced {{ }} actions, correct field names on the Container struct (name, port)","Confirm the struct passed to Execute exposes the fields the template references; rename template variables to match the struct"],"exampleFix":"// before: template references a field that no longer exists\nconst yamlTemplate = `...image: {{.ImageName}}...`\n// after: template fields match Container{name, name, port}\nconst yamlTemplate = `...image: {{.Name}}... port: {{.Port}}...`","handlingStrategy":"validation","validationCode":"// The template is embedded; validate it parses before relying on Generate\nt, err := template.New(\"check\").Parse(yamlTemplate)\nif err != nil {\n    return fmt.Errorf(\"embedded deployment template is corrupt; reinstall: %w\", err)\n}\n_ = t","typeGuard":null,"tryCatchPattern":"manifest, container, err := generator.Generate(name, port)\nif err != nil {\n    if strings.Contains(err.Error(), \"error parsing pod template\") {\n        return nil, fmt.Errorf(\"skaffold installation corrupted (template parse failed): %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Do not modify yamlTemplate in forked builds without running template unit tests","Verify binary integrity when installing Skaffold (checksums)","Add a startup smoke test that calls template.Parse on the embedded template"],"tags":["go-templates","kubernetes","manifest-generation"],"backgroundTag":"template-parse-failed","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"}