{"record":{"id":"a2fb42c28cc3d600","repo":"gohugoio/hugo","slug":"failed-to-decode-output-format-configuration-w","errorCode":null,"errorMessage":"failed to decode output format configuration: %w","messagePattern":"failed to decode output format configuration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/config.go","lineNumber":139,"sourceCode":"\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdataVal.SetMapIndex(key, reflect.ValueOf(mediaType))\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn nil, fmt.Errorf(\"invalid output format configuration; wrong type for media type, expected string (e.g. text/html), got %T\", vvi)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn c, nil\n\t\t},\n\t}\n\n\tdecoder, err := mapstructure.NewDecoder(config)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = decoder.Decode(input); err != nil {\n\t\treturn fmt.Errorf(\"failed to decode output format configuration: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":121,"sourceCodeEnd":144,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/output/config.go#L121-L144","documentation":"Thrown by output.decode (output/config.go:139) when mapstructure's decoder.Decode(input) returns an error while decoding a single output format's config map into a Format struct. The %w wraps the mapstructure error, which usually indicates an unrecognized field, a type that WeaklyTypedInput cannot coerce, or a struct field constraint violation (e.g. isHTML expects bool).","triggerScenarios":"A custom output format defines a field with an incompatible type (e.g. weight = \"abc\" where an int is expected, or isPlainText = \"yes\" which weak-typing may or may not coerce); an unknown field name that mapstructure rejects under its error policy; a nested structure where a scalar is expected.","commonSituations":"Typos in output format field names; copy-pasting a config snippet from a different Hugo version with renamed fields; using a string where a bool/int is required and weak typing cannot reconcile it.","solutions":["Read the wrapped mapstructure error to find the offending field name and expected type.","Correct the field value type in [outputFormats.NAME] to match the Format struct (BaseName string, Rel string, IsHTML bool, etc.).","Remove any unrecognized/renamed fields.","Run hugo config to verify the resolved outputFormats section parses cleanly."],"exampleFix":"# before\n[outputFormats.MYFORMAT]\nmediaType = \"text/html\"\nweight = \"heavy\"   # expects int\n\n# after\n[outputFormats.MYFORMAT]\nmediaType = \"text/html\"\nweight = 10","handlingStrategy":"try-catch","validationCode":"// Pre-validate known Format fields against expected types.\nvar formatFieldTypes = map[string]string{\n    \"baseName\": \"string\", \"rel\": \"string\", \"weight\": \"int\", \"isHTML\": \"bool\",\n}","typeGuard":null,"tryCatchPattern":"if err := output.DecodeConfig(mediaTypes, in); err != nil {\n    return fmt.Errorf(\"fix outputFormats field types: %w\", err)\n}","preventionTips":["Match each outputFormat field to the documented type.","Remove deprecated/renamed fields after Hugo upgrades.","Use `hugo config` to confirm clean parsing."],"tags":["output-formats","config","mapstructure","type-mismatch","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}