GoogleContainerTools/skaffold · error
error parsing pod template: %w
Error message
error parsing pod template: %w
What it means
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).
Source
Thrown at pkg/skaffold/kubernetes/generator/generate.go:37
import (
"bytes"
"fmt"
"html/template"
)
type Container struct {
Name string
Image string
Port int
}
// Generate generates kubernetes resources for the given image, and returns the generated manifest string
func Generate(name string, port int) ([]byte, *Container, error) {
c := Container{name, name, port}
t, err := template.New("deployment").Parse(yamlTemplate)
if err != nil {
return nil, nil, fmt.Errorf("error parsing pod template: %w", err)
}
var buf bytes.Buffer
if err = t.Execute(&buf, c); err != nil {
return nil, nil, fmt.Errorf("error executing template: %w", err)
}
return buf.Bytes(), &c, nil
}
View on GitHub (pinned to a1189de023)
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
Example fix
// before: template references a field that no longer exists
const yamlTemplate = `...image: {{.ImageName}}...`
// after: template fields match Container{name, name, port}
const yamlTemplate = `...image: {{.Name}}... port: {{.Port}}...` Defensive patterns
Strategy: validation
Validate before calling
// The template is embedded; validate it parses before relying on Generate
t, err := template.New("check").Parse(yamlTemplate)
if err != nil {
return fmt.Errorf("embedded deployment template is corrupt; reinstall: %w", err)
}
_ = t Try / catch
manifest, container, err := generator.Generate(name, port)
if err != nil {
if strings.Contains(err.Error(), "error parsing pod template") {
return nil, fmt.Errorf("skaffold installation corrupted (template parse failed): %w", err)
}
return nil, err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error executing template: %w
- c.Message (pod status condition message)
- unable to lookup minikube executable. Please add it to PATH
- invalid local-registry-hosting ConfigMap
- strings.Join(errMsgs, "\n") (joined helm cleanup error messa
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/7fbbd0865c21b2a4.
Report an issue: GitHub.