{"record":{"id":"0a22866da2232e3d","repo":"kubernetes/kops","slug":"unknown-output-format-q-0a2286","errorCode":null,"errorMessage":"unknown output format: %q","messagePattern":"unknown output format: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/kops/validate_cluster.go","lineNumber":227,"sourceCode":"\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 {\n\t\t\t\t\ttime.Sleep(options.interval)\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cluster passed validation %d consecutive times\", consecutive)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn result, nil\n\t\t\t}\n\t\t} else {\n\t\t\tif options.wait > 0 {\n\t\t\t\tklog.Warningf(\"(will retry): cluster not yet healthy\")","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/validate_cluster.go#L209-L245","documentation":"This is the final write of marshalled JSON results failing (identical to error 537's write path — it appears twice because both JSON/YAML share the wrap message). It indicates the OS-level write of the JSON output failed after successful marshalling, e.g. broken pipe to a dead consumer or closed output stream.","triggerScenarios":"`kops validate cluster -o json` piped to a consumer that exits before reading all output, or stdout redirected to a closed/full file.","commonSituations":"CI log streaming ending early; shell pipelines with early-terminating commands; disk quota exceeded on redirection target.","solutions":["Write output to a file instead of a pipe, then post-process.","Check disk space and file permissions on the redirection target.","Ensure the pipe consumer reads to EOF before exiting.","Inspect the wrapped %v cause in stderr to identify the syscall error."],"exampleFix":"// before\nkops validate cluster -o json | consumer\n// after\nkops validate cluster -o json > /tmp/out.json && consumer < /tmp/out.json","handlingStrategy":"try-catch","validationCode":"if fi, err := os.Stdout.Stat(); err == nil && (fi.Mode()&os.ModeNamedPipe) != 0 {\n\t// stdout is a pipe: confirm consumer stays alive\n\t_ = fi\n}","typeGuard":null,"tryCatchPattern":"_, err := runValidateCluster(ctx, options)\nif err != nil && strings.Contains(err.Error(), \"error writing to output\") {\n\t// retry writing to a file-backed buffer\n\tbuf := &bytes.Buffer{}\n\treturn writeValidateJSON(ctx, options, buf)\n}","preventionTips":["Avoid early-exiting pipeline consumers; buffer to a file first.","Check for EPIPE specifically to detect dead consumers.","Verify CI log sinks stay attached for the full command duration.","Set `set -o pipefail` in shell scripts to surface write errors."],"tags":["io","json","output"],"backgroundTag":"output-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"}