{"record":{"id":"a664b23ee38298da","repo":"kubernetes/kops","slug":"reading-file-q-v","errorCode":null,"errorMessage":"reading file %q: %v","messagePattern":"reading file %q: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete.go","lineNumber":95,"sourceCode":"\treturn cmd\n}\n\nfunc RunDelete(ctx context.Context, factory *util.Factory, out io.Writer, d *DeleteOptions) error {\n\t// We could have more than one cluster in a manifest so we are using a set\n\tdeletedClusters := sets.NewString()\n\n\tfor _, f := range d.Filenames {\n\t\tvar contents []byte\n\t\tvar err error\n\t\tif f == \"-\" {\n\t\t\tcontents, err = ConsumeStdin()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"reading from stdin: %v\", err)\n\t\t\t}\n\t\t} else {\n\t\t\tcontents, err = factory.VFSContext().ReadFile(f)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"reading file %q: %v\", f, err)\n\t\t\t}\n\t\t}\n\n\t\tsections := text.SplitContentToSections(contents)\n\t\tfor _, section := range sections {\n\t\t\to, gvk, err := kopscodecs.Decode(section, nil)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"parsing file %q: %v\", f, err)\n\t\t\t}\n\n\t\t\tswitch v := o.(type) {\n\t\t\tcase *kopsapi.Cluster:\n\t\t\t\toptions := &DeleteClusterOptions{\n\t\t\t\t\tClusterName: v.ObjectMeta.Name,\n\t\t\t\t\tYes:         d.Yes,\n\t\t\t\t}\n\t\t\t\terr = RunDeleteCluster(ctx, factory, out, options)\n\t\t\t\tif err != nil {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete.go#L77-L113","documentation":"Returned when `factory.VFSContext().ReadFile(f)` fails reading a file (or VFS location like s3://) passed to `kops delete -f`. The VFS context supports local files and cloud URLs; the wrapped error (not found, permission denied, S3 error) identifies the actual cause.","triggerScenarios":"Running `kops delete -f <path>` where the path doesn't exist, is unreadable, or the remote VFS URL (e.g. s3://bucket/manifest.yaml) can't be fetched due to missing credentials or wrong region.","commonSituations":"Typo'd manifest path; deleted or renamed manifest file; reading from an S3 URL without valid AWS credentials or with a wrong region; running from a different working directory with a relative path.","solutions":["Verify the file/URL exists (`ls -l <path>` or `aws s3 ls <url>`) and correct typos.","For remote URLs, confirm cloud credentials and region are configured correctly.","Run from the intended working directory or switch to absolute paths."],"exampleFix":"// before\nkops delete -f manifests/cluter.yaml\n// after\nkops delete -f manifests/cluster.yaml","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nif (target.startsWith('s3://')) {\n  execSync(`aws s3 ls ${target}`, { stdio: 'inherit' }); // creds/reachability check\n} else if (!fs.existsSync(target)) {\n  throw new Error(`delete manifest not found: ${target}`);\n}","typeGuard":"function manifestReadable(target) {\n  try { return require('fs').accessSync(target, require('fs').constants.R_OK) === undefined; } catch { return false; }\n}","tryCatchPattern":"try {\n  runKops(['delete', '-f', target]);\n} catch (e) {\n  if (/reading file/.test(e.message)) {\n    console.error(`Cannot read ${target}; verify path or VFS credentials.`);\n  }\n  throw e;\n}","preventionTips":["Pin absolute paths to manifests in scripts","Configure cloud credentials before VFS reads","Keep delete manifests under version control so they aren't deleted accidentally"],"tags":["cli","filesystem","vfs","delete","kops"],"backgroundTag":"file-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}