{"record":{"id":"e6f5e7ab552d56a6","repo":"run-llama/llama_index","slug":"previous-object-must-be-a-single-relatednodeinfo-o","errorCode":null,"errorMessage":"Previous object must be a single RelatedNodeInfo object","messagePattern":"Previous object must be a single RelatedNodeInfo object","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/schema.py","lineNumber":414,"sourceCode":"\n        \"\"\"\n        if NodeRelationship.SOURCE not in self.relationships:\n            return None\n\n        relation = self.relationships[NodeRelationship.SOURCE]\n        if isinstance(relation, list):\n            raise ValueError(\"Source object must be a single RelatedNodeInfo object\")\n        return relation\n\n    @property\n    def prev_node(self) -> Optional[RelatedNodeInfo]:\n        \"\"\"Prev node.\"\"\"\n        if NodeRelationship.PREVIOUS not in self.relationships:\n            return None\n\n        relation = self.relationships[NodeRelationship.PREVIOUS]\n        if not isinstance(relation, RelatedNodeInfo):\n            raise ValueError(\"Previous object must be a single RelatedNodeInfo object\")\n        return relation\n\n    @property\n    def next_node(self) -> Optional[RelatedNodeInfo]:\n        \"\"\"Next node.\"\"\"\n        if NodeRelationship.NEXT not in self.relationships:\n            return None\n\n        relation = self.relationships[NodeRelationship.NEXT]\n        if not isinstance(relation, RelatedNodeInfo):\n            raise ValueError(\"Next object must be a single RelatedNodeInfo object\")\n        return relation\n\n    @property\n    def parent_node(self) -> Optional[RelatedNodeInfo]:\n        \"\"\"Parent node.\"\"\"\n        if NodeRelationship.PARENT not in self.relationships:\n            return None","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/schema.py#L396-L432","documentation":"TextNode.prev_node reads relationships[NodeRelationship.PREVIOUS] and requires a RelatedNodeInfo instance specifically. Unlike SOURCE (which rejects any list), PREVIOUS must be exactly that type — a dict, a list, or any other shape raises ValueError.","triggerScenarios":"Assigning node.relationships[NodeRelationship.PREVIOUS] = {\"node_id\": ...} (a plain dict) or a list instead of a RelatedNodeInfo instance, then reading .prev_node.","commonSituations":"Building nodes from raw dicts/deserialized JSON where relationships were reconstructed as plain dictionaries; copy-pasting the CHILD list pattern into PREVIOUS.","solutions":["Wrap the value in RelatedNodeInfo: RelatedNodeInfo(**your_dict)","Rebuild nodes through TextNode/Document constructors or node parsers, which produce well-typed relationships","Validate relationships with a check that PREVIOUS is isinstance(x, RelatedNodeInfo) before storing to a docstore"],"exampleFix":"# before\nnode.relationships[NodeRelationship.PREVIOUS] = {\"node_id\": prev_id}\n\n# after\nfrom llama_index.core.schema import RelatedNodeInfo\nnode.relationships[NodeRelationship.PREVIOUS] = RelatedNodeInfo(node_id=prev_id)","handlingStrategy":"validation","validationCode":"from llama_index.core.schema import RelatedNodeInfo, NodeRelationship\nrel = node.relationships.get(NodeRelationship.PREVIOUS)\nif rel is not None and not isinstance(rel, RelatedNodeInfo):\n    node.relationships[NodeRelationship.PREVIOUS] = RelatedNodeInfo.model_validate(rel)","typeGuard":"def has_valid_prev(node) -> bool:\n    rel = node.relationships.get(NodeRelationship.PREVIOUS)\n    return rel is None or type(rel).__name__ == \"RelatedNodeInfo\"","tryCatchPattern":null,"preventionTips":["Always construct relationships with RelatedNodeInfo instances","Coerce dicts from external data via RelatedNodeInfo.model_validate","Use core node parsers to build prev/next chains"],"tags":["schema","nodes","relationships","data-validation"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}