GoogleContainerTools/skaffold · error
invalid output type: %q. Must be "plain" or "json"
Error message
invalid output type: %q. Must be "plain" or "json"
What it means
The `skaffold schema list` command supports exactly two `--output` formats: `plain` and `json`. Any other value passed to the output flag causes list() to return this error instead of rendering the schema version list. It is a strict input-validation guard on the output flag.
Source
Thrown at cmd/skaffold/app/cmd/schema/list.go:42
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema"
)
var OutputType string
// List prints to `out` all supported schema versions.
func List(_ context.Context, out io.Writer) error {
return list(out, OutputType)
}
func list(out io.Writer, outputType string) error {
switch outputType {
case "json":
return printJSON(out)
case "plain":
return printPlain(out)
default:
return fmt.Errorf(`invalid output type: %q. Must be "plain" or "json"`, outputType)
}
}
type schemaList struct {
Versions []string `json:"versions"`
}
func printJSON(out io.Writer) error {
return json.NewEncoder(out).Encode(schemaList{
Versions: versions(),
})
}
func printPlain(out io.Writer) error {
for _, version := range versions() {
fmt.Fprintln(out, version)
}
View on GitHub (pinned to a1189de023)
Solutions
- Use `--output json` or `--output plain` (lowercase, exact spelling).
- Omit the --output flag if a default format is acceptable.
- Check the flag value in your script/CI with `echo` before invoking skaffold.
Example fix
// before skaffold schema list --output yaml // after skaffold schema list --output json
Defensive patterns
Strategy: validation
Validate before calling
out := os.Getenv("SKAFFOLD_OUTPUT")
if out != "" && out != "plain" && out != "json" {
return fmt.Errorf("unsupported --output value %q; use \"plain\" or \"json\"", out)
} Type guard
func validSchemaOutput(v string) bool { return v == "plain" || v == "json" } Try / catch
if err := listCmd.Run(); err != nil {
if strings.Contains(err.Error(), "invalid output type") {
// fall back to default output
}
} Prevention
- Only pass exactly "plain" or "json" (lowercase) to --output.
- In scripts, whitelist the output value before invoking the CLI.
When it happens
Trigger: Running `skaffold schema list --output yaml`, `--output table`, `--output ''`, or any misspelled value such as `--output Json` (matching is case-sensitive via the switch).
Common situations: Users familiar with other CLI tools (kubectl uses -o yaml/json) assume more formats exist; typos in scripts; shell variables expanding to an empty or wrong value.
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
- `apply` requires at least one manifest argument
- `exec` requires exactly one action to execute
- `config-dependencies add` requires exactly one file path arg
- `jobManifestPaths modify` requires exactly one manifest file
- `inspect namespaces list` requires exactly one manifest file
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/e288e90022445177.
Report an issue: GitHub.