GoogleContainerTools/skaffold · error
kustomization parse error in %v: %w
Error message
kustomization parse error in %v: %w
What it means
DependenciesForKustomization reads a kustomization.yaml (or kustomize.yml/kustomization.yml/Kustomization) and unmarshals it into the kustomization struct. If YAML parsing fails, it reports 'kustomization parse error in <path>'. Recursion continues into bases/resources/components after a successful parse.
Source
Thrown at pkg/skaffold/render/generate/util.go:103
// provided working dir, and collects them into a list of files to be passed
// to the file watcher.
func DependenciesForKustomization(dir string) ([]string, error) {
var deps []string
path, err := FindKustomizationConfig(dir)
if err != nil {
// No kustomization config found so assume it's remote and stop traversing
return deps, nil
}
buf, err := os.ReadFile(path)
if err != nil {
return nil, err
}
content := kustomization{}
if err := yaml.Unmarshal(buf, &content); err != nil {
return nil, fmt.Errorf("kustomization parse error in %v: %w", path, err)
}
deps = append(deps, path)
candidates := append(content.Bases, content.Resources...)
candidates = append(candidates, content.Components...)
for _, candidate := range candidates {
// If the file doesn't exist locally, we can assume it's a remote file and
// skip it, since we can't monitor remote files. Kustomize itself will
// handle invalid/missing files.
local, mode := pathExistsLocally(candidate, dir)
if !local {
continue
}
if mode.IsDir() {
candidateDeps, err := DependenciesForKustomization(filepath.Join(dir, candidate))View on GitHub (pinned to a1189de023)
Solutions
- Validate the file: kustomize build <dir> (or kubectl kustomize <dir>) to see the YAML error
- Fix indentation/tabs and ensure list fields (resources, bases, components) are YAML lists
- Remove or correct fields unsupported by Skaffold's bundled yaml schema version
- Restore the file if it was truncated or auto-merged incorrectly
Example fix
// before (invalid) resources: base // after resources: - base
Defensive patterns
Strategy: validation
Validate before calling
kustomize build ./deploy/overlays/dev > /dev/null || echo 'kustomization invalid'
Try / catch
if err != nil && strings.Contains(err.Error(), "kustomization parse error") {
// parse the path from the message and run kustomize build there for the YAML detail
} Prevention
- Run kustomize build in CI as a lint step for every kustomization
- Keep list fields (resources, bases, components) as YAML lists
- Avoid fields unsupported by your Skaffold/kustomize version
When it happens
Trigger: A kustomization file under a path listed in kustomizeDependencies is malformed YAML or contains fields of the wrong type, so yaml.Unmarshal fails during dependency discovery (also recursed through nested bases).
Common situations: Hand-edited kustomization.yaml with bad indentation or tabs; wrong type for a list field (resources given as a string); kustomization written for a much newer kustomize schema with unsupported keys; truncated file from a failed merge.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- parsing skaffold config: %w
- unmarshalling global skaffold config: %w
- reading Kubernetes YAML: %w
- no Kustomization configuration found in directory: %s
- failed to apply setter to file %s, err: %v
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/c1e82edcee1f010f.
Report an issue: GitHub.