{"record":{"id":"5b55e818e2c9b3ca","repo":"kubernetes/kops","slug":"unknown-output-format-q-5b55e8","errorCode":null,"errorMessage":"unknown output format: %q","messagePattern":"unknown output format: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/get_cluster.go","lineNumber":188,"sourceCode":"\tif options.Output != OutputTable {\n\t\tfor _, c := range clusters {\n\t\t\tobj = append(obj, c)\n\t\t}\n\t}\n\n\tswitch options.Output {\n\tcase OutputTable:\n\t\treturn clusterOutputTable(clusters, out)\n\tcase OutputYaml:\n\t\treturn fullOutputYAML(out, obj...)\n\tcase OutputJSON:\n\t\t// if singleClusterSelected is true, only a single object is returned\n\t\t// otherwise to keep it consistent, always returns an array.\n\t\t// Ex: kops get clusters -ojson should will always return an array (even if 1 cluster is available)\n\t\t// kops get cluster test.example.com -o json will return a single object (since a specific cluster is selected)\n\t\treturn fullOutputJSON(out, singleClusterSelected, obj...)\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown output format: %q\", options.Output)\n\t}\n}\n\n// filterClustersByName returns the clusters matching the specified names.\n// If names are specified and no cluster is found with a name, we return an error.\nfunc filterClustersByName(clusterNames []string, clusters []*kopsapi.Cluster) ([]*kopsapi.Cluster, error) {\n\tif len(clusterNames) != 0 {\n\t\t// Build a map as we want to return them in the same order as args\n\t\tm := make(map[string]*kopsapi.Cluster)\n\t\tfor _, c := range clusters {\n\t\t\tm[c.ObjectMeta.Name] = c\n\t\t}\n\t\tvar filtered []*kopsapi.Cluster\n\t\tfor _, clusterName := range clusterNames {\n\t\t\tc := m[clusterName]\n\t\t\tif c == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"cluster not found %q\", clusterName)\n\t\t\t}","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/get_cluster.go#L170-L206","documentation":"RunGetClusters switches on the --output (-o) flag; any value other than table/yaml/json (the handled cases) reaches the default branch and returns 'unknown output format'. The flag value is taken verbatim from user input with no preprocessing.","triggerScenarios":"`kops get clusters -o YAML`, `-o yml`, `-o text`, or any misspelled format string.","commonSituations":"Case-sensitivity mistakes (YAML vs yaml); muscle-memory from other tools that accept 'table' variants or abbreviations; templating scripts with interpolated format variables.","solutions":["Use one of the supported values exactly: `-o table` (default), `-o yaml`, or `-o json`.","Fix casing — the comparison is case-sensitive, so `-o YAML` must become `-o yaml`.","If the value comes from a variable, validate/normalize it (e.g. `echo \"$fmt\" | tr 'A-Z' 'a-z'`) before invoking kops."],"exampleFix":"// before\nkops get clusters -o YAML\n// after\nkops get clusters -o yaml","handlingStrategy":"validation","validationCode":"fmt=\"${OUTPUT_FMT:-table}\"\ncase \"$(echo \"$fmt\" | tr '[:upper:]' '[:lower:]')\" in\n  table|yaml|json) ;;\n  *) echo \"unsupported output: $fmt (use table|yaml|json)\" >&2; exit 1;;\nesac","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Normalize format strings to lowercase before passing -o.","Whitelist allowed values in wrapper scripts.","Remember kops accepts only table, yaml, json — no abbreviations or alternate spellings."],"tags":["cli","output-format","argument-validation"],"backgroundTag":"invalid-output-format","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}