{"record":{"id":"0adaec0e77f39c5c","repo":"run-llama/llama_index","slug":"node-content-not-found-in-metadata-dict","errorCode":null,"errorMessage":"Node content not found in metadata dict.","messagePattern":"Node content not found in metadata dict\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/vector_stores/utils.py","lineNumber":83,"sourceCode":"    # dump remainder of node_dict to json string\n    metadata[\"_node_content\"] = json.dumps(node_dict, ensure_ascii=False)\n    metadata[\"_node_type\"] = node.class_name()\n\n    # store ref doc id at top level to allow metadata filtering\n    # kept for backwards compatibility, will consolidate in future\n    metadata[\"document_id\"] = node.ref_doc_id or \"None\"  # for Chroma\n    metadata[\"doc_id\"] = node.ref_doc_id or \"None\"  # for Pinecone, Qdrant, Redis\n    metadata[\"ref_doc_id\"] = node.ref_doc_id or \"None\"  # for Weaviate\n\n    return metadata\n\n\ndef metadata_dict_to_node(metadata: dict, text: Optional[str] = None) -> BaseNode:\n    \"\"\"Common logic for loading Node data from metadata dict.\"\"\"\n    node_json = metadata.get(\"_node_content\")\n    node_type = metadata.get(\"_node_type\")\n    if node_json is None:\n        raise ValueError(\"Node content not found in metadata dict.\")\n\n    node: BaseNode\n    if node_type == Node.class_name():\n        node = Node.from_json(node_json)\n    elif node_type == IndexNode.class_name():\n        node = IndexNode.from_json(node_json)\n    elif node_type == ImageNode.class_name():\n        node = ImageNode.from_json(node_json)\n    else:\n        node = TextNode.from_json(node_json)\n\n    if text is not None:\n        node.set_content(text)\n\n    return node\n\n\ndef build_metadata_filter_fn(","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/vector_stores/utils.py#L65-L101","documentation":"`metadata_dict_to_node` reconstructs a BaseNode from the metadata dict a vector store returns; the serialized node JSON is expected under the `_node_content` key (with `_node_type` selecting the class). If `_node_content` is absent — None or missing — there is nothing to deserialize, so it raises immediately. Typical causes are stores that were never given node content, custom metadata pipelines that strip underscore-prefixed keys, or legacy stores predating the `_node_content` convention.","triggerScenarios":"Calling `metadata_dict_to_node(metadata)` on a dict lacking `_node_content` — e.g. metadata round-tripped through SimpleVectorStore without stores_text, hand-built metadata dicts, or a store integration that returns only user metadata; also hit via `legacy_metadata_dict_to_node`-adjacent paths when content fields were never persisted.","commonSituations":"Building VectorStoreIndex with `stores_text=False` or inserting raw embedding tuples without node content; sanitizing metadata for third-party systems that drop underscore keys; upgrading from very old persist formats where node data lived in separate fields; querying stores where content embedding was stored but the JSON blob was not.","solutions":["Ensure nodes were added with full metadata (`node_to_metadata_dict(..., remove_text=False)`) so `_node_content` is persisted.","If underscore keys were stripped externally, stop filtering them or restore them before conversion.","For legacy dicts, use `legacy_metadata_dict_to_node` which reads the older field layout.","If the store simply has no node content, retrieve the node from the docstore instead of metadata."],"exampleFix":"# before\nnode = metadata_dict_to_node({\"_node_type\": \"TEXT\", \"doc_id\": \"x\"})  # ValueError\n\n# after\nnode = metadata_dict_to_node(store_metadata)  # where store_metadata[\"_node_content\"] exists\n# or, for old layouts:\nnode_info, text, ref_doc = legacy_metadata_dict_to_node(old_metadata)","handlingStrategy":"validation","validationCode":"def metadata_has_node_content(metadata: dict) -> bool:\n    return metadata.get(\"_node_content\") is not None","typeGuard":null,"tryCatchPattern":"try:\n    node = metadata_dict_to_node(metadata)\nexcept ValueError as e:\n    if \"Node content not found\" in str(e):\n        node = index.docstore.get_node(node_id)  # fallback\n    else:\n        raise","preventionTips":["Persist nodes with node_to_metadata_dict(remove_text=False) when you plan to rehydrate.","Never strip underscore-prefixed metadata keys in downstream systems.","Keep _node_content/_node_type fields out of user-facing filter surfaces."],"tags":["metadata","deserialization","vector-store","persistence","python"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}