{"record":{"id":"08b0e63f23bc1d09","repo":"run-llama/llama_index","slug":"score-not-set","errorCode":null,"errorMessage":"Score not set.","messagePattern":"Score not set\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/schema.py","lineNumber":1047,"sourceCode":"\n    @classmethod\n    def class_name(cls) -> str:\n        return \"IndexNode\"\n\n\nclass NodeWithScore(BaseComponent):\n    node: SerializeAsAny[BaseNode]\n    score: Optional[float] = None\n\n    def __str__(self) -> str:\n        score_str = \"None\" if self.score is None else f\"{self.score: 0.3f}\"\n        return f\"{self.node}\\nScore: {score_str}\\n\"\n\n    def get_score(self, raise_error: bool = False) -> float:\n        \"\"\"Get score.\"\"\"\n        if self.score is None:\n            if raise_error:\n                raise ValueError(\"Score not set.\")\n            else:\n                return 0.0\n        else:\n            return self.score\n\n    @classmethod\n    def class_name(cls) -> str:\n        return \"NodeWithScore\"\n\n    ##### pass through methods to BaseNode #####\n    @property\n    def node_id(self) -> str:\n        return self.node.node_id\n\n    @property\n    def id_(self) -> str:\n        return self.node.id_\n","sourceCodeStart":1029,"sourceCodeEnd":1065,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/schema.py#L1029-L1065","documentation":"NodeWithScore.get_score() raises ValueError('Score not set.') only when called with raise_error=True and the node's score is None. Nodes produced by retrievers that do not compute similarity (keyword/BM25-style, list-index linear scan, or manually constructed NodeWithScore) carry score=None.","triggerScenarios":"Calling node_with_score.get_score(raise_error=True) on a node whose score was never assigned — e.g. nodes returned from a no-score retriever or built as NodeWithScore(node=n) without a score argument.","commonSituations":"Post-processing code that assumes every retrieved node is scored; mixing nodes from BM25/keyword retrieval with rerankers that require scores.","solutions":["Call get_score() without raise_error (defaults to 0.0 for missing scores) when 0 is an acceptable default","Check .score is None explicitly and skip/assign a default before calling with raise_error=True","Use a similarity-based retriever (vector index) if real scores are required downstream"],"exampleFix":"# before\nscore = nws.get_score(raise_error=True)  # ValueError when score is None\n\n# after\nscore = nws.score if nws.score is not None else 0.0\n# or: score = nws.get_score()  # returns 0.0 instead of raising","handlingStrategy":"validation","validationCode":"if nws.score is None:\n    score = 0.0  # or skip node\nelse:\n    score = nws.score","typeGuard":"def is_scored(nws) -> bool:\n    return nws.score is not None","tryCatchPattern":null,"preventionTips":["Use get_score() default (0.0) unless errors are required","Filter nodes by .score is not None before reranking","Know which retrievers emit scores before relying on them"],"tags":["schema","retrieval","scoring"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}