kubernetes/kops · error
unsupported output type %q
Error message
unsupported output type %q
What it means
In DryRun mode the switch over c.Output only accepts yaml and json; any other --output value falls into the default branch and returns this error immediately. It is a user input validation error, not a runtime failure.
Source
Thrown at cmd/kops/create_cluster.go:820
}
for _, o := range addons {
obj = append(obj, o.ToUnstructured())
}
switch c.Output {
case OutputYaml:
if err := fullOutputYAML(out, obj...); err != nil {
return fmt.Errorf("error writing cluster yaml to stdout: %v", err)
}
return nil
case OutputJSON:
if err := fullOutputJSON(out, true, obj...); err != nil {
return fmt.Errorf("error writing cluster json to stdout: %v", err)
}
return nil
default:
return fmt.Errorf("unsupported output type %q", c.Output)
}
}
// Note we perform as much validation as we can, before writing a bad config
err = registry.CreateClusterConfig(ctx, clientset, cluster, instanceGroups, addons)
if err != nil {
return fmt.Errorf("error writing updated configuration: %v", err)
}
if len(c.SSHPublicKeys) == 0 {
autoloadSSHPublicKeys := true
switch c.CloudProvider {
case "gce", "aws":
autoloadSSHPublicKeys = false
}
if autoloadSSHPublicKeys {
// Load from default locations, if foundView on GitHub (pinned to 4c8573c808)
Solutions
- Use --output yaml or --output json exactly (lowercase).
- Omit --dry-run if you want the default behavior instead of serialized output.
- Check `kops create cluster --help` for supported output values.
Example fix
// before kops create cluster ... --dry-run --output yml // after kops create cluster ... --dry-run --output yaml
Defensive patterns
Strategy: validation
Validate before calling
output := strings.ToLower(c.Output)
if output != "yaml" && output != "json" {
return fmt.Errorf("--output must be yaml or json, got %q", c.Output)
} Type guard
func isValidOutputFormat(s string) bool {
return s == "yaml" || s == "json"
} Prevention
- Only pass yaml or json (lowercase) to --output.
- Grep scripts for --output flags and assert valid values in CI.
- Never interpolate arbitrary env vars into --output without defaulting (e.g. ${OUTPUT:-yaml}).
- Consult `kops create cluster --help` before scripting new formats.
When it happens
Trigger: `kops create cluster --dry-run --output <something-other-than-yaml|json>`, e.g. --output yml, --output text, or --output Yaml (matching is case-sensitive).
Common situations: Typo (yml vs yaml); assuming other kops commands' output formats (e.g. table) apply here; passing an env-expanded empty string as --output.
Related errors
- unable to execute --dry-run without setting --output
- error writing cluster yaml to stdout: %v
- error writing cluster json to stdout: %v
- --project cannot be empty; specify a project or omit the fla
- cannot specify --key with "all"
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/d3970031be1665f6.
Report an issue: GitHub.