{"record":{"id":"d6de1066b9220082","repo":"gohugoio/hugo","slug":"related-threshold-must-be-between-0-and-100","errorCode":null,"errorMessage":"related threshold must be between 0 and 100","messagePattern":"related threshold must be between 0 and 100","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"related/inverted_index.go","lineNumber":575,"sourceCode":"\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 {\n\t\t\tc.Indices[i].ToLower = true\n\t\t}\n\t}\n\tfor i := range c.Indices {\n\t\t// Lower case name.\n\t\tc.Indices[i].Name = strings.ToLower(c.Indices[i].Name)\n\n\t\ticfg := c.Indices[i]\n\t\tif icfg.Type == \"\" {\n\t\t\tc.Indices[i].Type = TypeBasic\n\t\t}\n\t\tif !validTypes[c.Indices[i].Type] {\n\t\t\treturn c, fmt.Errorf(\"invalid index type %q. Must be one of %v\", c.Indices[i].Type, maps.Keys(validTypes))\n\t\t}","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/related/inverted_index.go#L557-L593","documentation":"Returned by related.DecodeConfig in related/inverted_index.go:575 when the decoded Threshold is less than 0 or greater than 100. The related-content index uses threshold as a 0-100 relevance cutoff (normalized via the norm() helper above), so out-of-range values are rejected.","triggerScenarios":"Setting `threshold` under [related] to a negative number or a value above 100 in hugo.toml, or passing such a value in a programmatic related config map.","commonSituations":"Misreading threshold as a 0-1 float (setting 0.8) or as a percentile above 100, or a copy-paste from a different config schema.","solutions":["Set threshold to an integer in [0,100]; typical values are 60-90.","If you intended a 0-1 scale, multiply by 100 (0.8 -> 80).","Re-run `hugo config` to confirm the resolved threshold is in range."],"exampleFix":"// before\n[related]\nthreshold = 0.8\n// after\n[related]\nthreshold = 80","handlingStrategy":"validation","validationCode":"// Clamp/validate threshold into [0,100].\nif c.Threshold < 0 || c.Threshold > 100 {\n    return errors.New(\"threshold out of range\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat threshold as an integer 0-100, not a 0-1 float.","Validate config ranges in CI.","Use 60-90 as a sane starting point."],"tags":["related","config","validation","threshold"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}