{"record":{"id":"fb7ff335d732c67a","repo":"gohugoio/hugo","slug":"failed-to-decode-page-map-w-fb7ff3","errorCode":null,"errorMessage":"failed to decode page map: %w","messagePattern":"failed to decode page map: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/pagemeta/page_frontmatter.go","lineNumber":443,"sourceCode":"\t\t\tp.ContentMediaType = MarkupToMediaType(s, mediaTypes)\n\t\t}\n\t}\n\n\tif p.ContentMediaType.IsZero() {\n\t\treturn fmt.Errorf(\"failed to resolve media type for %q\", s)\n\t}\n\n\tif p.Content.Markup == \"\" {\n\t\tp.Content.Markup = p.ContentMediaType.SubType\n\t}\n\treturn nil\n}\n\n// Compile sets up the page configuration after all fields have been set.\nfunc (p *PageConfigLate) Compile(e *PageConfigEarly, logger loggers.Logger, outputFormats output.Formats) error {\n\tif e.IsFromContentAdapter {\n\t\tif err := mapstructure.WeakDecode(p.ContentAdapterData, p); err != nil {\n\t\t\terr = fmt.Errorf(\"failed to decode page map: %w\", err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif p.Params == nil {\n\t\tp.Params = make(hmaps.Params)\n\t} else {\n\t\thmaps.PrepareParams(p.Params)\n\t}\n\n\tif len(p.Outputs) > 0 {\n\t\toutFormats, err := outputFormats.GetByNames(p.Outputs...)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to resolve output formats %v: %w\", p.Outputs, err)\n\t\t} else {\n\t\t\tp.ConfiguredOutputFormats = outFormats\n\t\t}\n\t}","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/page/pagemeta/page_frontmatter.go#L425-L461","documentation":"Thrown by PageConfigLate.Compile when a page is flagged as coming from a content adapter (IsFromContentAdapter) and mapstructure.WeakDecode of ContentAdapterData into the PageConfigLate struct fails. The wrapped error is the decode failure, meaning the data map produced by the adapter does not fit the page-config schema.","triggerScenarios":"A content adapter populates ContentAdapterData with keys whose types are incompatible with PageConfigLate fields, e.g. 'weight: \"five\"' (string into int) or 'outputs: 42' (int into []string).","commonSituations":"Custom content adapters feeding unvalidated data from an external API/JSON into page config; schema drift between the adapter's source data and Hugo's PageConfigLate fields after an upgrade.","solutions":["Inspect the wrapped error for the offending field name and type mismatch.","Coerce the adapter's data values to the types expected by PageConfigLate (int for Weight, []string for Outputs, bool for Draft, etc.).","Keep unknown/extra keys under Params rather than at the top level of the data map."],"exampleFix":"// before\ndata := map[string]any{\"weight\": \"5\", \"outputs\": \"html\"}\n// after\ndata := map[string]any{\"weight\": 5, \"outputs\": []string{\"html\"}}","handlingStrategy":"try-catch","validationCode":"if err := mapstructure.WeakDecode(data, &pagemeta.PageConfigLate{}); err != nil {\n    return fmt.Errorf(\"adapter data shape invalid: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := pcfg.Compile(early, logger, formats); err != nil {\n    logger.Errorf(\"content adapter data for %s: %v\", path, err)\n    return err\n}","preventionTips":["Coerce adapter data field types to match PageConfigLate before assignment.","Keep extra data under Params, not top-level config keys.","Write integration tests for adapters against the current PageConfigLate schema."],"tags":["hugo","content-adapter","front-matter","type-mismatch","configuration"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}