{"record":{"id":"53687f450e69b5ee","repo":"gohugoio/hugo","slug":"no-related-config-provided","errorCode":null,"errorMessage":"no related config provided","messagePattern":"no related config provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"related/inverted_index.go","lineNumber":561,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\n\treturn result, nil\n}\n\n// normalizes num to a number between 0 and 100.\nfunc norm(num, min, max int) int {\n\tif min > max {\n\t\tpanic(\"min > max\")\n\t}\n\treturn int(math.Floor((float64(num-min) / float64(max-min) * 100) + 0.5))\n}\n\n// DecodeConfig decodes a slice of map into Config.\nfunc DecodeConfig(m hmaps.Params) (Config, error) {\n\tif m == nil {\n\t\treturn Config{}, errors.New(\"no related config provided\")\n\t}\n\n\tif len(m) == 0 {\n\t\treturn Config{}, errors.New(\"empty related config provided\")\n\t}\n\n\tvar c Config\n\n\tif err := mapstructure.WeakDecode(m, &c); err != nil {\n\t\treturn c, err\n\t}\n\n\tif c.Threshold < 0 || c.Threshold > 100 {\n\t\treturn Config{}, errors.New(\"related threshold must be between 0 and 100\")\n\t}\n\n\tif c.ToLower {\n\t\tfor i := range c.Indices {","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/related/inverted_index.go#L543-L579","documentation":"Returned by related.DecodeConfig in related/inverted_index.go:561 when the config map passed in is nil. DecodeConfig runs during config load to build the related-content index configuration; a nil map means no related config was supplied at all.","triggerScenarios":"Calling related.DecodeConfig(nil) programmatically, or a config merge path that yields a nil related-config value. In normal Hugo usage the related section defaults to a non-nil map, so this typically arises from custom/embedded configs.","commonSituations":"An embedded Hugo build that constructs config programmatically and omits the related section, or a config loader bug that returns nil instead of an empty map.","solutions":["Pass a non-nil (even if empty) map to DecodeConfig when building config programmatically.","In hugo.toml, provide a [related] block so the loader yields a populated map.","If you intentionally want no related index, supply an empty map (note that triggers error 58 instead — configure at least threshold/indices)."],"exampleFix":"// before\ncfg, err := related.DecodeConfig(nil)\n// after\ncfg, err := related.DecodeConfig(hmaps.Params{})","handlingStrategy":"validation","validationCode":"// Pass a non-nil related config map.\nif relatedCfg == nil { relatedCfg = hmaps.Params{} }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass nil to related.DecodeConfig.","Provide a [related] block or rely on Hugo defaults.","In embedded configs, default to an empty map (then populate)."],"tags":["related","config","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}