{"record":{"id":"eef8c2186d69f267","repo":"kubernetes/kops","slug":"error-writing-to-output-v-eef8c2","errorCode":null,"errorMessage":"error writing to output: %v","messagePattern":"error writing to output: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/validate_cluster.go","lineNumber":216,"sourceCode":"\t\t\t\ttime.Sleep(options.interval)\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected error during validation: %v\", err)\n\t\t\t}\n\t\t}\n\n\t\tswitch options.output {\n\t\tcase OutputTable:\n\t\t\tif err := validateClusterOutputTable(result, cluster, instanceGroups, out); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase OutputYaml:\n\t\t\ty, err := yaml.Marshal(result)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"unable to marshal YAML: %v\", err)\n\t\t\t}\n\t\t\tif _, err := out.Write(y); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error writing to output: %v\", err)\n\t\t\t}\n\t\tcase OutputJSON:\n\t\t\tj, err := json.Marshal(result)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"unable to marshal JSON: %v\", err)\n\t\t\t}\n\t\t\tif _, err := out.Write(j); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error writing to output: %v\", err)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"unknown output format: %q\", options.output)\n\t\t}\n\n\t\tif len(result.Failures) == 0 {\n\t\t\tconsecutive++\n\t\t\tif consecutive < options.count {\n\t\t\t\tklog.Infof(\"(will retry): cluster passed validation %d consecutive times\", consecutive)\n\t\t\t\tif options.wait > 0 {","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/validate_cluster.go#L198-L234","documentation":"RunValidateCluster wraps the failure of writing marshaled YAML validation results to the command's output writer. It fires in the --output yaml branch when the underlying io.Writer (stdout/file) errors, e.g. a closed or broken pipe; the JSON branch has the analogous error.","triggerScenarios":"Thrown at cmd/kops/validate_cluster.go:216 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that stdout is not closed or a redirected file is writable","Use table output as a fallback","Capture output to a file with proper permissions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}