{"record":{"id":"16cc1c1adcec91ec","repo":"gohugoio/hugo","slug":"failed-to-decode-q-w","errorCode":null,"errorMessage":"failed to decode %q: %w","messagePattern":"failed to decode %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/allconfig.go","lineNumber":1218,"sourceCode":"\t\t\t} else {\n\t\t\t\tlogger.Warnf(\"Skip unknown config key %q\", key)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Sort them to get the dependency order right.\n\tsort.Slice(decoderSetups, func(i, j int) bool {\n\t\tki, kj := decoderSetups[i], decoderSetups[j]\n\t\tif ki.weight == kj.weight {\n\t\t\treturn ki.key < kj.key\n\t\t}\n\t\treturn ki.weight < kj.weight\n\t})\n\n\tfor _, v := range decoderSetups {\n\t\tp := decodeConfig{p: p, c: target, fs: fs, bcfg: bcfg, logger: logger}\n\t\tif err := v.decode(v, p); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to decode %q: %w\", v.key, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc createDefaultOutputFormats(allFormats output.Formats) map[string][]string {\n\tif len(allFormats) == 0 {\n\t\tpanic(\"no output formats\")\n\t}\n\trssOut, rssFound := allFormats.GetByName(output.RSSFormat.Name)\n\thtmlOut, _ := allFormats.GetByName(output.HTMLFormat.Name)\n\n\tdefaultListTypes := []string{htmlOut.Name}\n\tif rssFound {\n\t\tdefaultListTypes = append(defaultListTypes, rssOut.Name)\n\t}\n","sourceCodeStart":1200,"sourceCodeEnd":1236,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/config/allconfig/allconfig.go#L1200-L1236","documentation":"Generic decoder-level error emitted by decodeConfigFromParams. It runs each registered section decoder (an entry in allDecoderSetups: build, languages, markup, mediatypes, outputformats, caches, etc.) in dependency order. When any single decoder returns an error, it is wrapped with that decoder's key so you know which top-level config section failed. This is the common ancestor of the more specific \"failed to decode languages config\" and \"failed to decode related config\" errors.","triggerScenarios":"Any malformed top-level config section: a `[build]` map with wrong field types, a `[markup]` sub-map that fails mapstructure decode, an `[outputformats]` entry missing a required field, a `[mediatypes]` entry with a bad suffix. Also reached via the per-language re-decode path.","commonSituations":"Typo in a config key; upgrading Hugo and a config field changed type or was renamed; pasting example config from an incompatible Hugo version; TOML/YAML/JSON syntax that parses but yields wrong-typed values.","solutions":["The wrapped error and the quoted key identify the failing section. Open that section and validate field types against current Hugo docs.","Run `hugo config` to see how far decoding got before failing.","Comment out the named section; if the build proceeds, the problem is isolated to it.","Compare the section against a freshly generated `hugo new site` default."],"exampleFix":"# before (outputformats missing isPlainText)\n[outputFormats.MYFORMAT]\nmediaType = \"text/html\"\n\n# after\n[outputFormats.MYFORMAT]\nmediaType = \"text/html\"\nisPlainText = true","handlingStrategy":"validation","validationCode":"# Lint config files for syntax before running hugo\n# TOML:\npython -c \"import tomllib,sys; tomllib.loads(open('hugo.toml').read())\" 2>&1 || echo \"TOML invalid\"\n# YAML:\npython -c \"import yaml,sys; yaml.safe_load(open('config.yaml'))\" 2>&1 || echo \"YAML invalid\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a config-syntax lint step to CI before `hugo build`.","After upgrading Hugo, run `hugo config` and resolve any renamed/retyped fields.","Start from a known-good `hugo new site` config and add sections incrementally."],"tags":["config","decoding","mapstructure"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}