{"record":{"id":"b60211aa441b097c","repo":"run-llama/llama_index","slug":"node-node-id-not-found","errorCode":null,"errorMessage":"Node {node_id} not found","messagePattern":"Node (.+?) not found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/storage/docstore/types.py","lineNumber":204,"sourceCode":"        self, node_id: str, raise_error: Literal[False] = False\n    ) -> Optional[BaseNode]: ...\n\n    def get_node(self, node_id: str, raise_error: bool = True) -> Optional[BaseNode]:\n        \"\"\"\n        Get node from docstore.\n\n        Args:\n            node_id (str): node id\n            raise_error (bool): raise error if node_id not found\n\n        \"\"\"\n        doc = self.get_document(node_id, raise_error=raise_error)\n\n        if doc is None:\n            # The doc store should have raised an error if the node_id is not found, but it didn't\n            # so we raise an error here\n            if raise_error:\n                raise ValueError(f\"Node {node_id} not found\")\n            return None\n\n        # The document should always be a BaseNode, but we check to be safe\n        if not isinstance(doc, BaseNode):\n            raise ValueError(f\"Document {node_id} is not a Node.\")\n\n        return doc\n\n    @overload\n    async def aget_node(\n        self, node_id: str, raise_error: Literal[True] = True\n    ) -> BaseNode: ...\n\n    @overload\n    async def aget_node(\n        self, node_id: str, raise_error: Literal[False] = False\n    ) -> Optional[BaseNode]: ...\n","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/storage/docstore/types.py#L186-L222","documentation":"BaseDocumentStore.get_node delegates to get_document(node_id) and raises this defensive ValueError when the returned object is None despite raise_error being requested. Normally get_document raises 'doc_id ... not found' first, so seeing this specific message means the underlying store returned None without raising (custom/overridden docstore behavior) -- plus a follow-on type check rejects non-Node results.","triggerScenarios":"docstore.get_node(node_id) where the node is absent and the concrete get_document implementation returns None instead of raising (e.g. a custom docstore subclass whose get_document ignores raise_error, or raise_error propagation is bypassed); also nodes looked up by a stale ID after deletion.","commonSituations":"Custom DocumentStore backends that do not honor the raise_error contract; retrieval flows resolving node IDs returned by a vector store after the docstore was partially cleared; tests with mock docstores returning None.","solutions":["Call get_node(node_id, raise_error=False) and handle None when absence is expected.","Pre-check with docstore.document_exists(node_id).","Fix custom get_document overrides to honor raise_error=True by raising, keeping the BaseDocumentStore contract.","Re-ingest or re-sync the docstore if vector-store node IDs point at missing docstore entries."],"exampleFix":"# before\nnode = docstore.get_node(node_id)  # ValueError: Node ... not found\n\n# after\nnode = docstore.get_node(node_id, raise_error=False)\nif node is None:\n    node = None  # skip / re-ingest source document","handlingStrategy":"validation","validationCode":"def get_node_or_none(docstore, node_id):\n    if not docstore.document_exists(node_id):\n        return None\n    return docstore.get_node(node_id)","typeGuard":"def node_exists(docstore, node_id: str) -> bool:\n    return docstore.document_exists(node_id)","tryCatchPattern":"try:\n    node = docstore.get_node(node_id)\nexcept ValueError as e:\n    if 'not found' in str(e):\n        node = None  # skip stale reference\n    else:\n        raise","preventionTips":["Use get_node(node_id, raise_error=False) in retrieval paths that tolerate missing nodes.","Custom docstore backends must honor the raise_error contract in get_document (raise, not return None).","Re-sync the docstore when vector-store results reference deleted node IDs."],"tags":["docstore","not-found","node","custom-backend","llama-index"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}