GoogleContainerTools/skaffold · error

kustomization parse error in %v: %w

Error message

kustomization parse error in %v: %w

What it means

DependenciesForKustomization fetches a kustomization file and unmarshals it into types.Kustomization. A YAML that is syntactically broken or not a valid Kustomization object yields this error, which wraps the yaml error. It occurs recursively while walking bases/resources/components.

Source

Thrown at pkg/skaffold/render/renderer/kustomize/kustomize.go:472

// 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 := types.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

  1. Run kubectl kustomize <dir> or kustomize build <dir> to see the parse error locally
  2. Fix the YAML syntax / field types in the named file
  3. Ensure apiVersion/kind fields exist and resources/bases/components are lists
  4. If the path resolved to a non-kustomization YAML, correct the path

Example fix

// before
resources: base
// after
resources:
  - base
Defensive patterns

Strategy: validation

Validate before calling

var k types.Kustomization
b, err := os.ReadFile(path)
if err != nil { return err }
if err := yaml.Unmarshal(b, &k); err != nil {
    return fmt.Errorf("pre-validate %s: %v", path, err)
}

Try / catch

if _, err := DependenciesForKustomization(path, &stringset.Set{}, nil); err != nil {
    return fmt.Errorf("kustomize tree invalid, aborting render: %w", err)
}

Prevention

When it happens

Trigger: A kustomization.yaml in the dependency tree fails yaml.Unmarshal into types.Kustomization (bad indentation, duplicate keys, wrong field types such as resources: as a string instead of a list).

Common situations: Hand-edited kustomization.yaml with indentation mistakes; using kustomize v1 'bases' syntax with a typo; tab characters in YAML; pulling a base via URL whose content is not a Kustomization.

Understand the failure class

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/6bc1b1050582e64c. Report an issue: GitHub.