{"record":{"id":"67ed3aeed14d8628","repo":"GoogleContainerTools/skaffold","slug":"reading-config-file-w-67ed3a","errorCode":null,"errorMessage":"reading config file: %w","messagePattern":"reading config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/kubernetes/util.go","lineNumber":98,"sourceCode":"// If so, it will return the parsed objects.\nfunc ParseKubernetesObjects(filepath string) ([]yamlObject, error) {\n\tf, err := os.Open(filepath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"opening config file: %w\", err)\n\t}\n\tdefer f.Close()\n\n\tr := k8syaml.NewYAMLReader(bufio.NewReader(f))\n\n\tvar k8sObjects []yamlObject\n\n\tfor {\n\t\tdoc, err := r.Read()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"reading config file: %w\", err)\n\t\t}\n\n\t\tobj := make(yamlObject)\n\t\tif err := yaml.Unmarshal(doc, &obj); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"reading Kubernetes YAML: %w\", err)\n\t\t}\n\n\t\tif !hasRequiredK8sManifestFields(obj) {\n\t\t\tcontinue\n\t\t}\n\n\t\tk8sObjects = append(k8sObjects, obj)\n\t}\n\tif len(k8sObjects) == 0 {\n\t\treturn nil, errors.New(\"no valid Kubernetes objects decoded\")\n\t}\n\treturn k8sObjects, nil\n}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/kubernetes/util.go#L80-L116","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the manifest path is a regular file, not a directory: `file <path>`","Re-run the command — transient I/O errors on network filesystems often clear","Check filesystem/mount health (dmesg or mount status) if using NFS/network volumes","Restore correct read permissions on the file"],"exampleFix":"// before (skaffold.yaml)\nmanifests:\n  - k8s/\n// after\nmanifests:\n  - k8s/*.yaml","handlingStrategy":"try-catch","validationCode":"// ensure the path is a regular readable file before parsing\nfi, err := os.Stat(path)\nif err != nil || fi.IsDir() {\n    return fmt.Errorf(\"%s must be a regular readable file\", path)\n}","typeGuard":null,"tryCatchPattern":"objects, err := kubernetes.ParseKubernetesObjects(path)\nif err != nil && strings.Contains(err.Error(), \"reading config file\") {\n    // transient I/O problem: retry once after a short delay\n    time.Sleep(500 * time.Millisecond)\n    objects, err = kubernetes.ParseKubernetesObjects(path)\n}\nreturn err","preventionTips":["Keep manifests on local disk, not flaky network mounts","Avoid mutating manifest files while skaffold is reading them","Point manifest config at files, not directories","Check mount health in environments using NFS/shared volumes"],"tags":["kubernetes","file-io","yaml"],"backgroundTag":"file-read-failure","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"}