{"record":{"id":"263ece6cd5c8f296","repo":"JanDeDobbeleer/oh-my-posh","slug":"invalid-export-format","errorCode":null,"errorMessage":"invalid export format","messagePattern":"invalid export format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/config_export.go","lineNumber":67,"sourceCode":"\t\tsetConfigFlag()\n\n\t\tcfg := config.Load(configFlag)\n\n\t\tvalidateExportFormat := func() error {\n\t\t\tformat = strings.ToLower(format)\n\t\t\tswitch format {\n\t\t\tcase config.JSON, config.JSONC:\n\t\t\t\tformat = config.JSON\n\t\t\tcase config.TOML, config.TML:\n\t\t\t\tformat = config.TOML\n\t\t\tcase config.YAML, config.YML:\n\t\t\t\tformat = config.YAML\n\t\t\tdefault:\n\t\t\t\tformats := []string{config.JSON, config.JSONC, config.TOML, config.TML, config.YAML, config.YML}\n\t\t\t\t// usage error\n\t\t\t\tfmt.Printf(\"export format must be one of these: %s\\n\", strings.Join(formats, \", \"))\n\t\t\t\texitcode = 2\n\t\t\t\treturn errors.New(\"invalid export format\")\n\t\t\t}\n\n\t\t\treturn nil\n\t\t}\n\n\t\tif len(format) != 0 {\n\t\t\tif err := validateExportFormat(); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif output == \"\" {\n\t\t\tfmt.Print(cfg.Export(format))\n\t\t\treturn\n\t\t}\n\n\t\tcfg.Source = cleanOutputPath(output)\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/config_export.go#L49-L85","documentation":"The `oh-my-posh config export` command was invoked with a `--format` value the exporter does not recognize. The CLI switches on the format string and the `default:` branch rejects anything outside the supported set (json, jsonc, toml, tml, yaml, yml). The command prints the accepted list to stdout and exits with status code 2 before any export happens.","triggerScenarios":"Running `oh-my-posh config export --format <value>` (or the equivalent `GetExport` flow) where format is not exactly one of config.JSON, JSONC, TOML, TML, YAML, YML — e.g. `--format yml ` with stray whitespace, `--format json5`, `--format YAML` if the comparison is case-sensitive, or a typo like `--format yam`.","commonSituations":"Users copying an example that uses an unsupported extension (`.ini`, `.json5`); scripting the flag from a config file extension that isn't mapped; passing uppercase or whitespace-padded values; confusing the export format with the config *read* format set.","solutions":["Use one of the exact accepted values: json, jsonc, toml, tml, yaml, yml.","Trim whitespace and match casing exactly as printed in the usage message (the error prints the full list).","Check the spelling of the flag value — 'yam', 'jsn', etc. all land in the default branch.","If scripting, validate the format value against the list before invoking the CLI so you get a clean failure."],"exampleFix":"// before\noh-my-posh config export --format json5 -o theme.json5\n// after\noh-my-posh config export --format jsonc -o theme.jsonc","handlingStrategy":"validation","validationCode":"var validFormats = map[string]bool{\"json\": true, \"jsonc\": true, \"toml\": true, \"tml\": true, \"yaml\": true, \"yml\": true}\nif !validFormats[strings.TrimSpace(format)] {\n    return fmt.Errorf(\"unsupported format %q; use json, jsonc, toml, tml, yaml, or yml\", format)\n}","typeGuard":null,"tryCatchPattern":"if err := exportConfig(format, out); err != nil {\n    if err.Error() == \"invalid export format\" {\n        fmt.Fprintln(os.Stderr, \"usage: --format json|jsonc|toml|tml|yaml|yml\")\n        os.Exit(2)\n    }\n    return err\n}","preventionTips":["Keep a shared const/list of accepted format strings and validate CLI input against it in scripts","Trim and normalize format values (lowercase, strip spaces) before passing to the CLI","Check `oh-my-posh config export --help` after upgrades in case the accepted set changes"],"tags":["cli","config","invalid-argument","usage"],"backgroundTag":"invalid-enum-value","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}