{"record":{"id":"221a03ca4bff3bde","repo":"kubernetes/kops","slug":"error-writing-to-output-v-221a03","errorCode":null,"errorMessage":"error writing to output: %v","messagePattern":"error writing to output: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/get_assets.go","lineNumber":164,"sourceCode":"\t\terr := assetcopy.Copy(updateClusterResults.ImageAssets, updateClusterResults.FileAssets, f.VFSContext(), updateClusterResults.Cluster)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tswitch options.Output {\n\tcase OutputTable:\n\t\tif err = imageOutputTable(result.Images, out); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn fileOutputTable(result.Files, out)\n\tcase OutputYaml:\n\t\ty, err := yaml.Marshal(result)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to marshal YAML: %v\", err)\n\t\t}\n\t\tif _, err := out.Write(y); err != nil {\n\t\t\treturn fmt.Errorf(\"error writing to output: %v\", err)\n\t\t}\n\tcase OutputJSON:\n\t\tj, err := json.Marshal(result)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to marshal JSON: %v\", err)\n\t\t}\n\t\tif _, err := out.Write(j); err != nil {\n\t\t\treturn fmt.Errorf(\"error writing to output: %v\", err)\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported output format: %q\", options.Output)\n\t}\n\n\treturn nil\n}\n\nfunc imageOutputTable(images []*Image, out io.Writer) error {\n\tfmt.Println(\"\")","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/get_assets.go#L146-L182","documentation":"After successfully marshaling the YAML bytes, RunGetAssets writes them to the provided io.Writer (stdout); any write failure is wrapped with this message. This is an I/O error, not a serialization error — the output stream rejected or failed the write.","triggerScenarios":"`kops get assets -o yaml` with stdout redirected to a full disk, a closed pipe (e.g. `| head`), or a broken file descriptor.","commonSituations":"Piping to commands that exit early (head, grep -q with immediate match); CI capturing output on a full filesystem; broken terminal/SSH session closing stdout.","solutions":["Redirect to a file instead of a pipe, or avoid consumers that close stdout early","Check available disk space on the target of the redirection","Rerun in a healthy terminal/SSH session to rule out closed descriptors"],"exampleFix":"// before\nkops get assets -o yaml | head -20\n// after\nkops get assets -o yaml > assets.yaml && head -20 assets.yaml","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := out.Write(y); err != nil {\n    if errors.Is(err, syscall.EPIPE) {\n        return nil // consumer closed stdout; benign\n    }\n    return fmt.Errorf(\"error writing to output: %v\", err)\n}","preventionTips":["Don't pipe to commands that exit early (head, grep -q)","Check disk space when redirecting output","Capture to a file for large asset listings","Ensure the terminal/SSH session stays open"],"tags":["io","output","stdout","cli"],"backgroundTag":"stdout-write-failed","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"}