{"record":{"id":"4bbb04f07cc8de10","repo":"gohugoio/hugo","slug":"failed-to-unmarshal-config-for-path-q-w","errorCode":null,"errorMessage":"failed to unmarshal config for path %q: %w","messagePattern":"failed to unmarshal config for path %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/configLoader.go","lineNumber":172,"sourceCode":"\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tif fi.IsDir() {\n\t\t\t\tdirnames = append(dirnames, path)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tif !IsValidConfigFilename(path) {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tname := paths.Filename(filepath.Base(path))\n\n\t\t\titem, err := metadecoders.Default.UnmarshalFileToMap(sourceFs, path)\n\t\t\tif err != nil {\n\t\t\t\t// This will be used in error reporting, use the most specific value.\n\t\t\t\tdirnames = []string{path}\n\t\t\t\treturn fmt.Errorf(\"failed to unmarshal config for path %q: %w\", path, err)\n\t\t\t}\n\n\t\t\tvar keyPath []string\n\t\t\tvar unwrapKey string\n\t\t\tif !DefaultConfigNamesSet[name] {\n\t\t\t\t// Can be params.jp, menus.en etc.\n\t\t\t\tname, lang := paths.FileAndExtNoDelimiter(name)\n\t\t\t\tunwrapKey = name\n\n\t\t\t\tkeyPath = []string{name}\n\n\t\t\t\tif lang != \"\" {\n\t\t\t\t\tkeyPath = []string{\"languages\", lang}\n\t\t\t\t\tswitch name {\n\t\t\t\t\tcase \"menu\", \"menus\":\n\t\t\t\t\t\tkeyPath = append(keyPath, \"menus\")\n\t\t\t\t\tcase \"params\":\n\t\t\t\t\t\tkeyPath = append(keyPath, \"params\")","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/config/configLoader.go#L154-L190","documentation":"During Hugo's config-file walk (config/configLoader.go:168), each candidate config file (hugo.toml/yaml/json, params.<lang>.*, menus.<lang>.*, etc.) is decoded into a map via metadecoders.UnmarshalFileToMap. This wraps the decode failure with the offending file path so the user knows exactly which file is malformed. The underlying error is a TOML/YAML/JSON syntax/parse error.","triggerScenarios":"Any syntax error in a config file under the project or theme config dir: malformed TOML table headers, bad YAML indentation or tabs, unquoted JSON, duplicate keys where forbidden, trailing junk after a value.","commonSituations":"Hand-editing hugo.toml and leaving an unterminated string or misplaced bracket; copy-pasting YAML with tabs from a browser; a params.en.yaml breaking after a theme/Hugo version upgrade that tightened parsing.","solutions":["Open the exact file named in the error and run it through the matching linter (tomllint / yamllint / a JSON validator).","Read the line/column carried in the wrapped %w error and fix that specific token.","Temporarily comment out the most recently edited section and re-add it incrementally to isolate the bad block.","Ensure you are using the correct format for the file extension (e.g. .toml content must be TOML, not YAML)."],"exampleFix":"# before (hugo.toml) -- missing closing bracket\n[params\nfoo = \"bar\"\n\n# after\n[params]\nfoo = \"bar\"","handlingStrategy":"validation","validationCode":"// Pre-validate a config file parses in its declared format before Hugo loads it.\nimport \"github.com/gohugoio/hugo/tpl/internal/go_templates/fmt\" // use metadecoders directly:\n// ok, err := metadecoders.Default.UnmarshalFileToMap(fs, path)\nfunc ValidateConfigFile(fs afero.Fs, path string) error {\n    _, err := metadecoders.Default.UnmarshalFileToMap(fs, path)\n    return err\n}","typeGuard":null,"tryCatchPattern":"// The loader already wraps the parse error with the path; check IsSet + the\n// returned err at the call site of LoadConfig.\ncfg, err := configLoader.LoadConfig(...)\nif err != nil {\n    return fmt.Errorf(\"loading config: %w\", err)\n}","preventionTips":["Run a TOML/YAML/JSON linter on config files in CI.","Keep one config format per file; match format to extension.","Avoid tabs in YAML; quote values containing special characters."],"tags":["config","toml","yaml","json","parsing"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}