GoogleContainerTools/skaffold · error

reading config file: %w

Error message

reading config file: %w

What it means

While reading multi-document YAML via k8syaml.YAMLReader, a Read() error other than io.EOF occurred and is wrapped as 'reading config file: %w'. This indicates the file could be opened but could not be read stream-wise — e.g. an I/O error or the path turned out to be a directory.

Source

Thrown at pkg/skaffold/kubernetes/util.go:98

// If so, it will return the parsed objects.
func ParseKubernetesObjects(filepath string) ([]yamlObject, error) {
	f, err := os.Open(filepath)
	if err != nil {
		return nil, fmt.Errorf("opening config file: %w", err)
	}
	defer f.Close()

	r := k8syaml.NewYAMLReader(bufio.NewReader(f))

	var k8sObjects []yamlObject

	for {
		doc, err := r.Read()
		if err == io.EOF {
			break
		}
		if err != nil {
			return nil, fmt.Errorf("reading config file: %w", err)
		}

		obj := make(yamlObject)
		if err := yaml.Unmarshal(doc, &obj); err != nil {
			return nil, fmt.Errorf("reading Kubernetes YAML: %w", err)
		}

		if !hasRequiredK8sManifestFields(obj) {
			continue
		}

		k8sObjects = append(k8sObjects, obj)
	}
	if len(k8sObjects) == 0 {
		return nil, errors.New("no valid Kubernetes objects decoded")
	}
	return k8sObjects, nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Confirm the manifest path is a regular file, not a directory: `file <path>`
  2. Re-run the command — transient I/O errors on network filesystems often clear
  3. Check filesystem/mount health (dmesg or mount status) if using NFS/network volumes
  4. Restore correct read permissions on the file

Example fix

// before (skaffold.yaml)
manifests:
  - k8s/
// after
manifests:
  - k8s/*.yaml
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the path is a regular readable file before parsing
fi, err := os.Stat(path)
if err != nil || fi.IsDir() {
    return fmt.Errorf("%s must be a regular readable file", path)
}

Try / catch

objects, err := kubernetes.ParseKubernetesObjects(path)
if err != nil && strings.Contains(err.Error(), "reading config file") {
    // transient I/O problem: retry once after a short delay
    time.Sleep(500 * time.Millisecond)
    objects, err = kubernetes.ParseKubernetesObjects(path)
}
return err

Prevention

When it happens

Trigger: ParseKubernetesObjects loops on r.Read(); a transient or hard I/O failure (read permission revoked mid-read, file on a failing mount, reader error on a directory opened as a file) surfaces here instead of EOF.

Common situations: Manifests stored on a network mount that dropped; a directory accidentally listed as a manifest path; file truncated/changed by another process while skaffold read it.

Related errors


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