{"id":"37d2fa4dedf66576","repo":"gohugoio/hugo","slug":"failed-to-create-config-from-result-w","errorCode":null,"errorMessage":"failed to create config from result: %w","messagePattern":"failed to create config from result: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/load.go","lineNumber":73,"sourceCode":"\t}\n\n\tif d.Logger == nil {\n\t\td.Logger = loggers.NewDefault()\n\t}\n\n\tl := &configLoader{ConfigSourceDescriptor: d, cfg: config.New()}\n\t// Make sure we always do this, even in error situations,\n\t// as we have commands (e.g. \"hugo mod init\") that will\n\t// use a partial configuration to do its job.\n\tdefer l.deleteMergeStrategies()\n\tres, _, err := l.loadConfigMain(d)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load config: %w\", err)\n\t}\n\n\tconfigs, err = fromLoadConfigResult(d.Fs, d.Logger, res)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create config from result: %w\", err)\n\t}\n\n\tmoduleConfig, modulesClient, err := l.loadModules(configs, d.IgnoreModuleDoesNotExist)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load modules: %w\", err)\n\t}\n\n\tif len(l.ModulesConfigFiles) > 0 {\n\t\t// Config merged in from modules.\n\t\t// Re-read the config.\n\t\tconfigs, err = fromLoadConfigResult(d.Fs, d.Logger, res)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create config from modules config: %w\", err)\n\t\t}\n\t\tif err := configs.transientErr(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create config from modules config: %w\", err)\n\t\t}\n\t\tconfigs.LoadingInfo.ConfigFiles = append(configs.LoadingInfo.ConfigFiles, l.ModulesConfigFiles...)","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/config/allconfig/load.go#L55-L91","documentation":"Returned when fromLoadConfigResult fails on the first pass — i.e. the raw merged config parsed fine, but constructing the typed per-language Config objects from it failed. This is where the alldecoders.go decoder table runs, so it wraps section-level decode/validation errors (languages, markup, outputs, security, related, ...) into one 'failed to create config from result' error.","triggerScenarios":"Any decoder in allDecoderSetups returning an error while transforming the merged config map into the typed Config: an invalid security whitelist regexp, bad [languages] or [related] blocks, invalid output formats or media types, unknown markup settings — anything that parses as TOML/YAML but is semantically invalid.","commonSituations":"Config that is syntactically valid but semantically wrong: values of the wrong type in a known section, options from a newer Hugo used on an older binary, theme-recommended config pasted without adaptation, per-language overrides that conflict with root settings.","solutions":["Look at the wrapped error after the prefix — it names the failing section (e.g. 'failed to decode languages config') and the actual problem.","Fix the identified section against the current Hugo docs for your version.","If the error appeared after a Hugo upgrade, check the release notes for renamed/removed config keys in that section.","Bisect by temporarily removing the implicated section to confirm, then reintroduce it corrected."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Most 'create config from result' failures are type mismatches; keep values typed correctly\n// e.g. booleans as true/false not \"true\", ints unquoted, durations/strings where documented","typeGuard":null,"tryCatchPattern":"conf, err := allconfig.LoadConfig(opts)\nif err != nil {\n    // decode-stage failure: the raw files parsed but a key had the wrong type/shape\n    // the wrapped mapstructure error names the offending key — surface it verbatim\n    return err\n}","preventionTips":["Match value types to the documented schema (quoted strings vs bare bools/ints are the top cause of decode failures)","Don't put scalar values where Hugo expects tables (e.g. params sections)","After config edits run hugo config to force a full decode locally","Pin the Hugo version so schema changes between releases don't silently break decoding"],"tags":["hugo","config","decoding","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}