{"record":{"id":"b1231d9426a3529d","repo":"run-llama/llama_index","slug":"could-not-infer-node-type-for-data-node-dict-s","errorCode":null,"errorMessage":"Could not infer node type for data: {node_dict!s}","messagePattern":"Could not infer node type for data: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/graph_stores/simple_labelled.py","lineNumber":214,"sourceCode":"        return cls.from_persist_path(persist_path, fs=fs)\n\n    @classmethod\n    def from_dict(\n        cls,\n        data: dict,\n    ) -> \"SimplePropertyGraphStore\":\n        \"\"\"Load from dict.\"\"\"\n        # need to load nodes manually\n        node_dicts = data[\"nodes\"]\n\n        kg_nodes: Dict[str, LabelledNode] = {}\n        for id, node_dict in node_dicts.items():\n            if \"name\" in node_dict:\n                kg_nodes[id] = EntityNode.model_validate(node_dict)\n            elif \"text\" in node_dict:\n                kg_nodes[id] = ChunkNode.model_validate(node_dict)\n            else:\n                raise ValueError(f\"Could not infer node type for data: {node_dict!s}\")\n\n        # clear the nodes, to load later\n        data[\"nodes\"] = {}\n\n        # load the graph\n        graph = LabelledPropertyGraph.model_validate(data)\n\n        # add the node back\n        graph.nodes = kg_nodes\n\n        return cls(graph)\n\n    def to_dict(self) -> dict:\n        \"\"\"Convert to dict.\"\"\"\n        return self.graph.model_dump()\n\n    # NOTE: Unimplemented methods for SimplePropertyGraphStore\n","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/graph_stores/simple_labelled.py#L196-L232","documentation":"Raised by SimplePropertyGraphStore.from_dict when a serialized node dict contains neither a 'name' key (which would make it an EntityNode) nor a 'text' key (which would make it a ChunkNode). Node type is inferred purely by key sniffing during manual deserialization, so any other shape is unrecoverable.","triggerScenarios":"Calling SimplePropertyGraphStore.from_dict(data) on hand-edited JSON, data exported from a different property-graph store version, or dicts whose node fields were renamed/filtered (e.g. serialized with exclude={'text'}) before saving.","commonSituations":"Schema drift between llama-index versions changing node serialization keys; round-tripping persisted graph JSON through external tools that drop empty strings (a node with text='' may lose the key); merging graphs from heterogeneous sources.","solutions":["Regenerate the persisted dict with the same llama-index version that reads it, so each node carries 'name' (entities) or 'text' (chunks).","Repair the data by adding the correct key per node type before from_dict: name for entities, text for chunks.","If the source is another store implementation, convert nodes explicitly to EntityNode/ChunkNode models instead of relying on from_dict inference."],"exampleFix":"# before\nstore = SimplePropertyGraphStore.from_dict(loaded_json)  # node missing name/text\n\n# after\nfor node in loaded_json[\"nodes\"].values():\n    if \"name\" not in node and \"text\" not in node:\n        node[\"text\"] = node.get(\"id\", \"\")  # or route to EntityNode with node[\"name\"] = ...\nstore = SimplePropertyGraphStore.from_dict(loaded_json)","handlingStrategy":"validation","validationCode":"for node_id, nd in data[\"nodes\"].items():\n    if \"name\" not in nd and \"text\" not in nd:\n        raise ValueError(f\"Node {node_id} lacks 'name'/'text'; cannot infer type\")\nstore = SimplePropertyGraphStore.from_dict(data)","typeGuard":"def all_nodes_have_type_key(node_dicts: dict) -> bool:\n    return all((\"name\" in nd) or (\"text\" in nd) for nd in node_dicts.values())","tryCatchPattern":null,"preventionTips":["Persist and reload graphs with the same llama-index version.","Never strip empty-string fields when post-processing serialized graphs (text='' still matters).","Pre-validate persisted JSON structure before from_dict."],"tags":["serialization","deserialization","schema-drift","data-corruption"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}