{"id":"4ed1f9802841c484","repo":"gohugoio/hugo","slug":"failed-to-create-config-w","errorCode":null,"errorMessage":"failed to create config: %w","messagePattern":"failed to create config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/load.go","lineNumber":93,"sourceCode":"\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...)\n\t} else if err := configs.transientErr(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create config: %w\", err)\n\t}\n\n\tconfigs.Modules = moduleConfig.AllModules\n\tconfigs.ModulesClient = modulesClient\n\n\tif !d.SkipNpmCheck && npm.NpmPackNeedsUpdate(d.Fs, configs.Modules) {\n\t\td.Logger.Warnln(`npm dependencies are out of sync, please run \"hugo mod npm pack\" (you may also want to run \"npm install\" after that)`)\n\t}\n\n\tif err := configs.Init(d.Fs, d.Logger); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to init config: %w\", err)\n\t}\n\n\tloggers.SetGlobalLogger(d.Logger)\n\n\treturn\n}\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/config/allconfig/load.go#L75-L111","documentation":"Returned on the no-modules-config path: when no module contributed config files, Hugo still checks configs.transientErr() and wraps any deferred validation error as 'failed to create config'. Transient errors are problems detected during typed-config construction that are deliberately deferred (so partial-config commands can still run) and only fatal here, at the end of a full LoadConfig.","triggerScenarios":"configs.transientErr() returning non-nil after fromLoadConfigResult succeeded — typically deferred per-language or cross-section validation failures recorded during construction of the per-language Config objects rather than raised immediately in a decoder.","commonSituations":"Cross-cutting config inconsistencies that only manifest once all languages/sections are assembled: per-language settings that individually parse but are jointly invalid, or deprecated/removed options recorded as deferred errors after a Hugo upgrade.","solutions":["Read the wrapped transient error text — it describes the actual invalid setting; fix that key in your config.","Check per-language override blocks ([languages.xx.*]) for values inconsistent with root config.","After a Hugo upgrade, run `hugo config` and review the release notes for options that became errors.","Reduce config to a minimal set and reintroduce sections to isolate the deferred failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Final construction validates cross-cutting invariants; pre-check the common ones\nif base := cfg.GetString(\"baseURL\"); base != \"\" {\n    if _, err := url.Parse(base); err != nil {\n        return fmt.Errorf(\"invalid baseURL: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"conf, err := allconfig.LoadConfig(opts)\nif err != nil {\n    // last-stage construction failure: individual sections decoded but the\n    // combined config is inconsistent (e.g. bad baseURL, conflicting language/output settings)\n    return err\n}","preventionTips":["Treat this as a cross-section consistency failure: check baseURL, defaultContentLanguage vs languages, outputFormats/mediaTypes references","Every custom output format must reference a defined media type and vice versa","Run hugo config in CI to exercise the full construction path on every config change","Fail the pipeline on any config error — never fall back to defaults silently"],"tags":["hugo","config","validation","multilingual"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}