{"record":{"id":"6d381f053ee15560","repo":"gohugoio/hugo","slug":"unsupported-format-q","errorCode":null,"errorMessage":"unsupported format: %q","messagePattern":"unsupported format: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/config.go","lineNumber":105,"sourceCode":"\tformat := strings.ToLower(c.format)\n\n\tswitch format {\n\tcase \"json\":\n\t\tos.Stdout.Write(buf.Bytes())\n\tdefault:\n\t\t// Decode the JSON to a map[string]interface{} and then unmarshal it again to the correct format.\n\t\tvar m map[string]any\n\t\tif err := json.Unmarshal(buf.Bytes(), &m); err != nil {\n\t\t\treturn err\n\t\t}\n\t\thmaps.ConvertFloat64WithNoDecimalsToInt(m)\n\t\tswitch format {\n\t\tcase \"yaml\":\n\t\t\treturn parser.InterfaceToConfig(m, metadecoders.YAML, os.Stdout)\n\t\tcase \"toml\":\n\t\t\treturn parser.InterfaceToConfig(m, metadecoders.TOML, os.Stdout)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unsupported format: %q\", format)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (c *configCommand) Init(cd *simplecobra.Commandeer) error {\n\tc.r = cd.Root.Command.(*rootCommand)\n\tcmd := cd.CobraCommand\n\tcmd.Short = \"Display project configuration\"\n\tcmd.Long = `Display project configuration, both default and custom settings.`\n\tcmd.Flags().StringVar(&c.format, \"format\", \"toml\", \"preferred file format (toml, yaml or json)\")\n\t_ = cmd.RegisterFlagCompletionFunc(\"format\", cobra.FixedCompletions([]string{\"toml\", \"yaml\", \"json\"}, cobra.ShellCompDirectiveNoFileComp))\n\tcmd.Flags().StringVar(&c.lang, \"lang\", \"\", \"the language to display config for. Defaults to the first language defined.\")\n\tcmd.Flags().BoolVar(&c.printZero, \"printZero\", false, `include config options with zero values (e.g. false, 0, \"\") in the output`)\n\t_ = cmd.RegisterFlagCompletionFunc(\"lang\", cobra.NoFileCompletions)\n\tapplyLocalFlagsBuildConfig(cmd, c.r)\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/config.go#L87-L123","documentation":"The hugo config --format command supports only json, yaml, and toml (config.go:99-106). The default format is toml. Any other format value falls through to the default case and returns this error.","triggerScenarios":"Running hugo config --format xml, --format ini, --format env, or any unsupported format string.","commonSituations":"Typo in the format name; assuming other serialization formats are supported; copy-paste errors.","solutions":["Use one of: json, yaml, or toml","Omit --format to use the default (toml)","Check the spelling of the format value"],"exampleFix":"# before\nhugo config --format xml\n# after\nhugo config --format yaml","handlingStrategy":"validation","validationCode":"// Validate the --format value.\nvar validConfigFormats = map[string]bool{\"json\": true, \"yaml\": true, \"toml\": true}\nfunc validateConfigFormat(format string) error {\n    if !validConfigFormats[strings.ToLower(format)] {\n        return fmt.Errorf(\"unsupported format: %q\", format)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only json, yaml, or toml for --format","Omit --format to use the default (toml)","Enable shell completion for the format flag"],"tags":["cli","config","format","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}