{"record":{"id":"d72506b421a1b96d","repo":"istio/istio","slug":"invalid-format-expected-one-of-v-but-got-q","errorCode":null,"errorMessage":"invalid format, expected one of %v but got %q","messagePattern":"invalid format, expected one of (.+?) but got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"istioctl/pkg/util/formatting/formatter.go","lineNumber":60,"sourceCode":")\n\nfunc init() {\n\tfor _, key := range MsgOutputFormatKeys {\n\t\tMsgOutputFormats[key] = true\n\t}\n}\n\n// Print output messages in the specified format with color options\nfunc Print(ms diag.Messages, format string, colorize bool) (string, error) {\n\tswitch format {\n\tcase LogFormat:\n\t\treturn printLog(ms, colorize), nil\n\tcase JSONFormat:\n\t\treturn printJSON(ms)\n\tcase YAMLFormat:\n\t\treturn printYAML(ms)\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"invalid format, expected one of %v but got %q\", MsgOutputFormatKeys, format)\n\t}\n}\n\nfunc printLog(ms diag.Messages, colorize bool) string {\n\tlogOutput := make([]string, 0, len(ms))\n\tfor _, m := range ms {\n\t\tlogOutput = append(logOutput, render(m, colorize))\n\t}\n\treturn strings.Join(logOutput, \"\\n\")\n}\n\nfunc printJSON(ms diag.Messages) (string, error) {\n\tjsonOutput, err := json.MarshalIndent(ms, \"\", \"\\t\")\n\treturn string(jsonOutput), err\n}\n\nfunc printYAML(ms diag.Messages) (string, error) {\n\tyamlOutput, err := yaml.Marshal(ms)","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/istio/istio/blob/8dc789c5cf17517c64e3c36cb3288230f149dfae/istioctl/pkg/util/formatting/formatter.go#L42-L78","documentation":"Print renders analysis/diagnostic messages in the requested output format and rejects anything outside the supported set (log, json, yaml — from MsgOutputFormatKeys). This is the istioctl `--output` / -o flag validator for analyze-style message output.","triggerScenarios":"Passing an unsupported -o value to commands that route through this Print (e.g. `istioctl analyze -o table`, `-o wide`, `-o xml`) — only log/json/yaml are accepted here, unlike kubectl's richer format set.","commonSituations":"Muscle memory from kubectl (`-o wide`, `-o name`, `-o jsonpath=...`) applied to istioctl analyze; scripts assuming table output is a valid format string.","solutions":["Use one of the printed valid keys: log, json, or yaml.","If you need machine-readable output for analysis results, use `-o json` or `-o yaml` and post-process with jq/yq.","Check MsgOutputFormatKeys in the istioctl version in use — the valid set is printed in the error."],"exampleFix":"# before\nistioctl analyze -o wide\n\n# after\nistioctl analyze -o json","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"log\": true, \"json\": true, \"yaml\": true}\nif !valid[format] {\n    return fmt.Errorf(\"unsupported format %q; use log|json|yaml\", format)\n}","typeGuard":"func IsValidMsgOutputFormat(f string) bool {\n    for _, k := range formatting.MsgOutputFormatKeys {\n        if f == k { return true }\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Restrict -o flags in wrapper scripts to the printed valid set.","Do not port kubectl format assumptions to istioctl.","Parse the error's valid-key list to auto-correct typos in interactive tools."],"tags":["istioctl","cli","output-format","validation"],"backgroundTag":null,"analyzedSha":"8dc789c5cf17517c64e3c36cb3288230f149dfae","analyzedAt":"2026-08-15T15:16:55.434Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}