{"record":{"id":"9b6b75b93fbd0627","repo":"kubernetes/kops","slug":"reading-from-stdin-v","errorCode":null,"errorMessage":"reading from stdin: %v","messagePattern":"reading from stdin: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete.go","lineNumber":90,"sourceCode":"\tcmd.AddCommand(NewCmdDeleteInstance(f, out))\n\tcmd.AddCommand(NewCmdDeleteInstanceGroup(f, out))\n\tcmd.AddCommand(NewCmdDeleteSecret(f, out))\n\tcmd.AddCommand(NewCmdDeleteSSHPublicKey(f, out))\n\n\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{","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete.go#L72-L108","documentation":"Returned by `kops delete -f -` when `ConsumeStdin` fails while reading the manifests from standard input. kOps reads the full stdin stream as the resource spec(s) to delete; an error reading the stream (e.g. closed/broken pipe) aborts the delete with this wrapper.","triggerScenarios":"Running `kops delete -f -` where stdin is closed, is not piped at all, or the producer process terminates mid-stream (broken pipe / EOF condition surfaced as an error).","commonSituations":"Shell pipelines like `kops get cluster -o yaml | kops delete -f -` where the upstream command fails; interactive shells with no stdin attached; CI runners without stdin allocated when `-` is accidentally used instead of a filename.","solutions":["Ensure something actually pipes data in: `cat resources.yaml | kops delete -f -`.","Check the upstream command in the pipeline succeeded before kOps consumed stdin.","If you meant to read a file, pass the filename instead of `-`."],"exampleFix":"// before (no stdin in CI)\nkops delete -f -\n// after\nkops delete -f resources.yaml","handlingStrategy":"try-catch","validationCode":"// ensure stdin has data when using '-'\nconst stdinData = fs.readFileSync(0, 'utf8'); // throws immediately if stdin empty/closed\nif (!stdinData.trim()) throw new Error('No manifest provided on stdin');","typeGuard":null,"tryCatchPattern":"try {\n  runKops(['delete', '-f', '-']);\n} catch (e) {\n  if (/reading from stdin/.test(e.message)) {\n    console.error('stdin read failed; pipe a manifest in or use -f <file>.');\n  }\n  throw e;\n}","preventionTips":["Prefer file-based -f paths in CI (no stdin allocated)","Check pipeline upstream exit codes","Never use '-' interactively without piping data"],"tags":["cli","stdin","delete","kops"],"backgroundTag":"stdin-read-failure","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"}