{"record":{"id":"6bbc68262d501eb3","repo":"gohugoio/hugo","slug":"config-not-set","errorCode":null,"errorMessage":"config not set","messagePattern":"config not set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/hugobuilder.go","lineNumber":81,"sourceCode":"\t// May be nil.\n\ts *serverCommand\n\n\t// Currently only set when in \"fast render mode\".\n\tchangeDetector *fileChangeDetector\n\tvisitedURLs    *types.EvictingQueue[string]\n\n\tfullRebuildSem *semaphore.Weighted\n\tdebounce       func(f func())\n\n\tonConfigLoaded func(reloaded bool) error\n\n\tfastRenderMode     bool\n\tshowErrorInBrowser bool\n\n\terrState hugoBuilderErrState\n}\n\nvar errConfigNotSet = errors.New(\"config not set\")\n\nfunc (c *hugoBuilder) withConfE(fn func(conf *commonConfig) error) error {\n\tc.confmu.Lock()\n\tdefer c.confmu.Unlock()\n\tif c.conf == nil {\n\t\treturn errConfigNotSet\n\t}\n\treturn fn(c.conf)\n}\n\nfunc (c *hugoBuilder) withConf(fn func(conf *commonConfig)) {\n\tc.confmu.Lock()\n\tdefer c.confmu.Unlock()\n\tfn(c.conf)\n}\n\nfunc (c *hugoBuilder) withConfOrOldConf(fn func(conf *commonConfig)) {\n\tc.confmu.Lock()","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/hugobuilder.go#L63-L99","documentation":"hugoBuilder.withConfE guards every access to the shared commonConfig; if c.conf is nil when a command tries to use it, the guard returns errConfigNotSet. This protects against commands running before configuration has been loaded.","triggerScenarios":"Calling a hugoBuilder method that routes through withConfE before c.conf has been populated by doConfigReload/ConfigFromProvider.","commonSituations":"A command path that skips config loading; a reload failure left c.conf nil; invoking builder helpers during early init.","solutions":["Ensure config loads successfully before invoking builder operations (fix the underlying config load error)","Confirm a valid Hugo project / config file exists in the working directory","Restart the server after fixing config so c.conf is repopulated"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := builder.withConfE(func(conf *commonConfig) error { ... }); err != nil {\n    if errors.Is(err, errConfigNotSet) { /* load config first, then retry */ }\n}","preventionTips":["Always run config load before issuing builder commands","Treat a nil conf as a fatal precondition failure"],"tags":["config","hugobuilder","go","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}