kubernetes/kops · warning
unknown output format: %q
Error message
unknown output format: %q
What it means
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.
Source
Thrown at cmd/kops/validate_cluster.go:227
}
case OutputYaml:
y, err := yaml.Marshal(result)
if err != nil {
return nil, fmt.Errorf("unable to marshal YAML: %v", err)
}
if _, err := out.Write(y); err != nil {
return nil, fmt.Errorf("error writing to output: %v", err)
}
case OutputJSON:
j, err := json.Marshal(result)
if err != nil {
return nil, fmt.Errorf("unable to marshal JSON: %v", err)
}
if _, err := out.Write(j); err != nil {
return nil, fmt.Errorf("error writing to output: %v", err)
}
default:
return nil, fmt.Errorf("unknown output format: %q", options.output)
}
if len(result.Failures) == 0 {
consecutive++
if consecutive < options.count {
klog.Infof("(will retry): cluster passed validation %d consecutive times", consecutive)
if options.wait > 0 {
time.Sleep(options.interval)
continue
} else {
return nil, fmt.Errorf("cluster passed validation %d consecutive times", consecutive)
}
} else {
return result, nil
}
} else {
if options.wait > 0 {
klog.Warningf("(will retry): cluster not yet healthy")View on GitHub (pinned to 4c8573c808)
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.
Example fix
// before kops validate cluster -o json | consumer // after kops validate cluster -o json > /tmp/out.json && consumer < /tmp/out.json
Defensive patterns
Strategy: try-catch
Validate before calling
if fi, err := os.Stdout.Stat(); err == nil && (fi.Mode()&os.ModeNamedPipe) != 0 {
// stdout is a pipe: confirm consumer stays alive
_ = fi
} Try / catch
_, err := runValidateCluster(ctx, options)
if err != nil && strings.Contains(err.Error(), "error writing to output") {
// retry writing to a file-backed buffer
buf := &bytes.Buffer{}
return writeValidateJSON(ctx, options, buf)
} Prevention
- 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.
When it happens
Trigger: `kops validate cluster -o json` piped to a consumer that exits before reading all output, or stdout redirected to a closed/full file.
Common situations: CI log streaming ending early; shell pipelines with early-terminating commands; disk quota exceeded on redirection target.
Related errors
- error writing to output: %v
- error writing cluster json to stdout: %v
- error writing json to stdout: %v
- error writing to output: %v
- writing output: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/0a22866da2232e3d.
Report an issue: GitHub.