{"record":{"id":"0fc50812a999bf7f","repo":"kubernetes/kops","slug":"unsupported-output-format-q-0fc508","errorCode":null,"errorMessage":"unsupported output format: %q","messagePattern":"unsupported output format: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/get_instances.go","lineNumber":178,"sourceCode":"\t\ty, err := yaml.Marshal(asRenderable(cloudInstances))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to marshal YAML: %v\", err)\n\t\t}\n\t\tif _, err := out.Write(y); err != nil {\n\t\t\treturn fmt.Errorf(\"error writing to output: %v\", err)\n\t\t}\n\t\treturn nil\n\tcase OutputJSON:\n\t\tj, err := json.Marshal(asRenderable(cloudInstances))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to marshal JSON: %v\", err)\n\t\t}\n\t\tif _, err := out.Write(j); err != nil {\n\t\t\treturn fmt.Errorf(\"error writing to output: %v\", err)\n\t\t}\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported output format: %q\", options.Output)\n\t}\n}\n\nfunc instanceOutputTable(instances []*cloudinstances.CloudInstance, out io.Writer) error {\n\tfmt.Println(\"\")\n\tt := &tables.Table{}\n\tt.AddColumn(\"ID\", func(i *cloudinstances.CloudInstance) string {\n\t\treturn i.ID\n\t})\n\tt.AddColumn(\"NODE-NAME\", func(i *cloudinstances.CloudInstance) string {\n\t\tnode := i.Node\n\t\tif node == nil {\n\t\t\treturn \"\"\n\t\t} else {\n\t\t\treturn node.Name\n\t\t}\n\t})\n\tt.AddColumn(\"STATUS\", func(i *cloudinstances.CloudInstance) string {","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/get_instances.go#L160-L196","documentation":"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.","triggerScenarios":"`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\".","commonSituations":"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.","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."],"exampleFix":"// before\nkops get instances -o JSON\n// after\nkops get instances -o json","handlingStrategy":"validation","validationCode":"case \"$OUTPUT\" in\n  table|yaml|json) ;;\n  *) echo \"invalid -o '$OUTPUT'; use table|yaml|json\" >&2; exit 2 ;;\nesac","typeGuard":null,"tryCatchPattern":"if err := runKops(\"get\", \"instances\", \"-o\", format); err != nil {\n\tif strings.Contains(err.Error(), \"unsupported output format\") {\n\t\treturn fmt.Errorf(\"format %q not supported: use table|yaml|json\", format)\n\t}\n\treturn err\n}","preventionTips":["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."],"tags":["cli","input-validation","flags"],"backgroundTag":"invalid-flag-value","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}