{"record":{"id":"7ad32850f4726e0d","repo":"run-llama/llama_index","slug":"nodes-must-be-a-list-of-node-objects","errorCode":null,"errorMessage":"nodes must be a list of Node objects.","messagePattern":"nodes must be a list of Node objects\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/indices/base.py","lineNumber":62,"sourceCode":"        transformations: Optional[List[TransformComponent]] = None,\n        show_progress: bool = False,\n        **kwargs: Any,\n    ) -> None:\n        \"\"\"Initialize with parameters.\"\"\"\n        if index_struct is None and nodes is None and objects is None:\n            raise ValueError(\"One of nodes, objects, or index_struct must be provided.\")\n        if index_struct is not None and nodes is not None and len(nodes) >= 1:\n            raise ValueError(\"Only one of nodes or index_struct can be provided.\")\n        # This is to explicitly make sure that the old UX is not used\n        if nodes is not None and len(nodes) >= 1 and not isinstance(nodes[0], BaseNode):\n            if isinstance(nodes[0], Document):\n                raise ValueError(\n                    \"The constructor now takes in a list of Node objects. \"\n                    \"Since you are passing in a list of Document objects, \"\n                    \"please use `from_documents` instead.\"\n                )\n            else:\n                raise ValueError(\"nodes must be a list of Node objects.\")\n\n        self._storage_context = storage_context or StorageContext.from_defaults()\n        self._docstore = self._storage_context.docstore\n        self._show_progress = show_progress\n        self._vector_store = self._storage_context.vector_store\n        self._graph_store = self._storage_context.graph_store\n        self._callback_manager = callback_manager or Settings.callback_manager\n\n        objects = objects or []\n        self._object_map = {obj.index_id: obj.obj for obj in objects}\n        for obj in objects:\n            obj.obj = None  # clear the object to avoid serialization issues\n\n        with self._callback_manager.as_trace(\"index_construction\"):\n            if index_struct is None:\n                nodes = nodes or []\n                index_struct = self.build_index_from_nodes(\n                    nodes + objects,  # type: ignore","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/indices/base.py#L44-L80","documentation":"BaseIndex's constructor validates that every element of the nodes argument is a BaseNode instance. Documents are caught by a friendlier message (error 165); any other type (raw strings, dicts, LangChain documents, arbitrary objects) triggers this generic ValueError telling you nodes must be Node objects.","triggerScenarios":"Passing strings, dicts, or third-party document objects in the nodes list; passing a list of Document subclasses that don't inherit BaseNode; passing a single node instead of a list of nodes where the first element is not a node.","commonSituations":"Interoperability code converting other frameworks' documents into llama-index without mapping to TextNode; JSON round-tripping nodes from storage and passing raw dicts; novice usage of index(nodes=[text, text]).","solutions":["Convert your items to llama-index nodes, e.g. [TextNode(text=t) for t in texts].","If starting from Documents, use from_documents or a node parser (SentenceSplitter) instead of hand-building nodes.","If loading persisted nodes, deserialize with the docstore (docstore.get_nodes) rather than reading JSON manually.","Add an isinstance check before constructing so bad items are caught with your own context."],"exampleFix":"# before\nindex = VectorStoreIndex(nodes=[\"chunk one\", \"chunk two\"])  # ValueError\n\n# after\nfrom llama_index.core.schema import TextNode\nindex = VectorStoreIndex(nodes=[TextNode(text=\"chunk one\"), TextNode(text=\"chunk two\")])","handlingStrategy":"type-guard","validationCode":"from llama_index.core.schema import BaseNode\nbad = [i for i, n in enumerate(nodes or []) if not isinstance(n, BaseNode)]\nif bad:\n    raise TypeError(f\"Non-node items at positions {bad}\")","typeGuard":"def all_nodes(items) -> bool:\n    return bool(items) and all(isinstance(n, BaseNode) for n in items)","tryCatchPattern":null,"preventionTips":["Convert external data to TextNode at the boundary of your pipeline.","Deserialize persisted nodes through the docstore, not raw JSON."],"tags":["index","constructor","type-validation","base-index"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}