{"record":{"id":"5cff96a308ec47ed","repo":"mudler/LocalAI","slug":"router-rerank-policy-q-has-no-description","errorCode":null,"errorMessage":"router/rerank: policy %q has no description","messagePattern":"router/rerank: policy %q has no description","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/services/routing/router/rerank.go","lineNumber":51,"sourceCode":"// defaultRerankActivationThreshold is the relevance floor a label\n// must clear to be considered active. Reranker scores live in [0, 1]\n// for cross-encoder / ColBERT heads; 0.5 picks \"more positive than\n// not on this label.\"\nconst defaultRerankActivationThreshold = 0.5\n\nfunc NewRerankClassifier(policies []ScorePolicy, reranker backend.Reranker, cacheCap int, activationThreshold float64) *RerankClassifier {\n\tif len(policies) == 0 {\n\t\tpanic(\"router/rerank: at least one policy is required\")\n\t}\n\tif reranker == nil {\n\t\tpanic(\"router/rerank: reranker is required (configure router.classifier_model)\")\n\t}\n\tfor _, p := range policies {\n\t\tif p.Label == \"\" {\n\t\t\tpanic(\"router/rerank: policy has empty label\")\n\t\t}\n\t\tif p.Description == \"\" {\n\t\t\tpanic(fmt.Sprintf(\"router/rerank: policy %q has no description\", p.Label))\n\t\t}\n\t}\n\tif activationThreshold <= 0 {\n\t\tactivationThreshold = defaultRerankActivationThreshold\n\t}\n\tlabels := make([]string, len(policies))\n\tdocs := make([]string, len(policies))\n\tfor i, p := range policies {\n\t\tlabels[i] = p.Label\n\t\tdocs[i] = p.Description\n\t}\n\treturn &RerankClassifier{\n\t\treranker:            reranker,\n\t\tactivationThreshold: activationThreshold,\n\t\tlabels:              labels,\n\t\tdocuments:           docs,\n\t\tcache:               newLabelSetCache(cacheCap),\n\t}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/core/services/routing/router/rerank.go#L33-L69","documentation":"Construction-time panic in NewRerankClassifier: a policy has a label but an empty Description. Descriptions are the documents the reranker scores the incoming prompt against — with no description the classifier could never activate that policy, so construction refuses.","triggerScenarios":"A policies entry with only a label (description key missing or empty string); YAML value quoted as empty (description: \"\"); a zero-value description after templating/config interpolation.","commonSituations":"Minimal config written from an example that truncated the description line; templating variable for description resolving to empty; misunderstanding description as optional metadata rather than required scoring input.","solutions":["Write a meaningful description for each policy describing the requests it should match","Audit every policy entry for both label and description keys","Treat descriptions as prompts: make them specific enough for the reranker to discriminate"],"exampleFix":"# before (yaml)\npolicies:\n  - label: code\n# after\npolicies:\n  - label: code\n    description: \"requests about writing, debugging, or explaining code\"","handlingStrategy":"validation","validationCode":"for i, p := range policies {\n    if strings.TrimSpace(p.Description) == \"\" {\n        return fmt.Errorf(\"policy %q: empty description\", p.Label)\n    }\n}","typeGuard":"func validDescriptions(ps []ScorePolicy) bool { for _, p := range ps { if p.Description == \"\" { return false } }; return true }","tryCatchPattern":null,"preventionTips":["Treat descriptions as required scoring input, not comments","Validate at config load with the label named in the error","Keep example configs complete with both fields"],"tags":["router","config","validation","panic"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}