{"record":{"id":"f5f0a4230a86bdee","repo":"k3s-io/k3s","slug":"invalid-output-format","errorCode":null,"errorMessage":"invalid output format: ","messagePattern":"invalid output format: ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cli/etcdsnapshot/etcd_snapshot.go","lineNumber":214,"sourceCode":"\t\treturn err\n\t}\n\treturn list(app, &cmds.ServerConfig)\n}\n\nvar etcdListFormats = []string{\"json\", \"yaml\", \"table\"}\n\nfunc validEtcdListFormat(format string) bool {\n\tfor _, supportedFormat := range etcdListFormats {\n\t\tif format == supportedFormat {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc list(app *cli.Context, cfg *cmds.Server) error {\n\tif cfg.EtcdListFormat != \"\" && !validEtcdListFormat(cfg.EtcdListFormat) {\n\t\treturn errors.New(\"invalid output format: \" + cfg.EtcdListFormat)\n\t}\n\n\tsr, info, err := commandSetup(app, cfg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsr.Operation = etcd.SnapshotOperationList\n\n\tb, err := json.Marshal(sr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr, err := info.Post(\"/db/snapshot\", b, clientaccess.WithTimeout(timeout))\n\tif err != nil {\n\t\treturn wrapServerError(err)\n\t}\n","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/cli/etcdsnapshot/etcd_snapshot.go#L196-L232","documentation":"`k3s etcd-snapshot list` accepts an output format via the list-format flag; validEtcdListFormat compares it against the fixed set {json, yaml, table}. Any other non-empty value fails immediately with this error before the list request is dispatched.","triggerScenarios":"Passing --format json|yaml|table with a typo or unsupported value: --format=JSON (case-sensitive), --format=custom, --format=name.","commonSituations":"Scripts assuming case-insensitive or extra formats (e.g. wide, custom-columns); CI parsing expecting a format k3s never supported; tab-completion inserting a wrong value.","solutions":["Use one of the supported values exactly: --format json, --format yaml, or --format table (default)","Fix case: JSON is rejected; use lowercase json","For machine consumption prefer json and pipe to jq"],"exampleFix":"# before\nk3s etcd-snapshot list --format JSON  # -> invalid output format: JSON\n\n# after\nk3s etcd-snapshot list --format json | jq .","handlingStrategy":"validation","validationCode":"func validFormat(f string) bool {\n    switch f { case \"\", \"json\", \"yaml\", \"table\": return true; default: return false }\n}\nif !validFormat(cfg.EtcdListFormat) {\n    return fmt.Errorf(\"unsupported --format %q; use json, yaml, or table\", cfg.EtcdListFormat)\n}","typeGuard":"func isEtcdListFormat(f string) bool { return slices.Contains([]string{\"json\", \"yaml\", \"table\"}, f) }","tryCatchPattern":null,"preventionTips":["Lowercase the flag in scripts before passing it","Pin CI parsing to --format json for stable machine output","Add a wrapper that whitelists formats and rejects typos early"],"tags":["etcd","snapshot","cli","output-format","validation"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}