kubernetes/kops · error
unknown output format: %q
Error message
unknown output format: %q
What it means
`kops get secrets` only supports a fixed set of --output values (table, text/yaml, json, depending on implementation). When options.Output holds any other string, the switch's default branch returns "unknown output format: %q". It is pure input validation of the -o/--output flag.
Source
Thrown at cmd/kops/get_secrets.go:168
var data string
secret, err := secretStore.FindSecret(item)
if err != nil {
return fmt.Errorf("getting secret %q: %v", item, err)
}
if secret == nil {
return fmt.Errorf("cannot find secret %q", item)
}
data = string(secret.Data)
_, err = fmt.Fprintf(out, "%s\n", data)
if err != nil {
return fmt.Errorf("writing output: %v", err)
}
}
return nil
default:
return fmt.Errorf("unknown output format: %q", options.Output)
}
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Run `kops get secrets --help` and use exactly one of the supported values (table/text, json, yaml as listed)
- Correct the flag, e.g. `-o json` instead of `-o xml`
- Quote/validate the variable supplying --output in scripts before invoking kops
Example fix
// before kops get secrets mysecret -o xml // after kops get secrets mysecret -o json
Defensive patterns
Strategy: validation
Validate before calling
case "$OUT" in table|text|json|yaml) ;; *) echo "unsupported --output '$OUT'; use table, text, json, yaml"; exit 1 ;; esac kops get secrets -o "$OUT"
Prevention
- Check `kops get secrets --help` for accepted --output values
- Never interpolate unvalidated variables into -o/--output
- Standardize on json or yaml for scripting
When it happens
Trigger: Invoking `kops get secrets --output xml`, `--output yaml` when only table/json are accepted, or passing an empty/garbled value via scripts or wrappers that set the flag programmatically.
Common situations: Typos in the flag value; copying examples from other k8s tools with different output names; CI scripts parameterizing the output format with an unvalidated variable.
Related errors
- unsupported output type %q
- --name is required
- cannot specify --cert with "all"
- unknown output format: %q
- unsupported output format: %q
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/64b613d5cb89752d.
Report an issue: GitHub.