kubernetes/kops · error
unsupported output format: %q
Error message
unsupported output format: %q
What it means
RunGetInstances validates the value of --output against the supported formats (table, yaml, json). The `default` branch of the switch rejects any other value with "unsupported output format: %q". This is pure input validation of the options.Output flag, raised before any rendering happens.
Source
Thrown at cmd/kops/get_instances.go:178
y, err := yaml.Marshal(asRenderable(cloudInstances))
if err != nil {
return fmt.Errorf("unable to marshal YAML: %v", err)
}
if _, err := out.Write(y); err != nil {
return fmt.Errorf("error writing to output: %v", err)
}
return nil
case OutputJSON:
j, err := json.Marshal(asRenderable(cloudInstances))
if err != nil {
return fmt.Errorf("unable to marshal JSON: %v", err)
}
if _, err := out.Write(j); err != nil {
return fmt.Errorf("error writing to output: %v", err)
}
return nil
default:
return fmt.Errorf("unsupported output format: %q", options.Output)
}
}
func instanceOutputTable(instances []*cloudinstances.CloudInstance, out io.Writer) error {
fmt.Println("")
t := &tables.Table{}
t.AddColumn("ID", func(i *cloudinstances.CloudInstance) string {
return i.ID
})
t.AddColumn("NODE-NAME", func(i *cloudinstances.CloudInstance) string {
node := i.Node
if node == nil {
return ""
} else {
return node.Name
}
})
t.AddColumn("STATUS", func(i *cloudinstances.CloudInstance) string {View on GitHub (pinned to 4c8573c808)
Solutions
- Pass one of the supported values: `kops get instances -o table|yaml|json`.
- Check spelling and case — the match is exact lowercase.
- Run `kops get instances --help` to see the accepted values.
- In scripts, validate the format variable before invoking the CLI.
Example fix
// before kops get instances -o JSON // after kops get instances -o json
Defensive patterns
Strategy: validation
Validate before calling
case "$OUTPUT" in table|yaml|json) ;; *) echo "invalid -o '$OUTPUT'; use table|yaml|json" >&2; exit 2 ;; esac
Try / catch
if err := runKops("get", "instances", "-o", format); err != nil {
if strings.Contains(err.Error(), "unsupported output format") {
return fmt.Errorf("format %q not supported: use table|yaml|json", format)
}
return err
} Prevention
- Whitelist formats in scripts before invoking the CLI.
- Remember formats are case-sensitive lowercase.
- Consult `kops get instances --help` rather than assuming kubectl-compatible formats.
- Pin format values in CI templates instead of interpolating free-form input.
When it happens
Trigger: `kops get instances -o xml`, `-o csv`, `-o JSON` (case-sensitive matching), or any misspelled/empty format string that does not equal "table", "yaml", or "json".
Common situations: Typo in a script's -o flag; assuming case-insensitive formats (JSON vs json); copying a flag value from another tool that supports more formats; automation templates built for a different kOps version.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- unknown output format: %q
- unsupported output type %q
- --name is required
- cannot specify --cert with "all"
- cannot use both --admin and --user
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/0fc50812a999bf7f.
Report an issue: GitHub.