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

  1. Write output to a file instead of a pipe, then post-process.
  2. Check disk space and file permissions on the redirection target.
  3. Ensure the pipe consumer reads to EOF before exiting.
  4. 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

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


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/0a22866da2232e3d. Report an issue: GitHub.