{"record":{"id":"08963dfd0b0d2e00","repo":"run-llama/llama_index","slug":"the-constructor-now-takes-in-a-list-of-node-object","errorCode":null,"errorMessage":"The constructor now takes in a list of Node objects. Since you are passing in a list of Document objects, please use `from_documents` instead.","messagePattern":"The constructor now takes in a list of Node objects\\. Since you are passing in a list of Document objects, please use `from_documents` instead\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/indices/base.py","lineNumber":56,"sourceCode":"        self,\n        nodes: Optional[Sequence[BaseNode]] = None,\n        objects: Optional[Sequence[IndexNode]] = None,\n        index_struct: Optional[IS] = None,\n        storage_context: Optional[StorageContext] = None,\n        callback_manager: Optional[CallbackManager] = None,\n        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","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/indices/base.py#L38-L74","documentation":"BaseIndex's constructor explicitly detects the pre-0.x API where Document objects were passed as nodes. Since the modern API takes BaseNode objects (TextNode etc.), passing Documents raises ValueError with a redirect to from_documents. This guard exists to make the old-to-new UX migration fail loudly instead of misbehaving.","triggerScenarios":"Calling VectorStoreIndex(documents) or any index constructor whose first positional argument receives Document objects (documents are positional arg #2, so this commonly happens with wrong argument order).","commonSituations":"Upgrading from old llama_index versions where GPTVectorStoreIndex(documents) was valid; argument-order mistakes such as VectorStoreIndex(docs, nodes) where documents land in the nodes slot; tutorials mixing old and new APIs.","solutions":["Use the factory: VectorStoreIndex.from_documents(documents).","If you already parsed documents into nodes yourself, pass those nodes: VectorStoreIndex(nodes=[TextNode(...), ...]).","Check argument order — only Node objects (not Document) may appear in the nodes parameter.","Transform documents to nodes explicitly via SentenceSplitter().get_nodes_from_documents(documents) if you need custom transformations."],"exampleFix":"# before (old / wrong API)\nindex = VectorStoreIndex(documents)  # ValueError: use from_documents\n\n# after\nindex = VectorStoreIndex.from_documents(documents)\n\n# or with manual node control\nfrom llama_index.core.node_parser import SentenceSplitter\nnodes = SentenceSplitter().get_nodes_from_documents(documents)\nindex = VectorStoreIndex(nodes)","handlingStrategy":"validation","validationCode":"from llama_index.core.schema import Document\nif nodes and isinstance(nodes[0], Document):\n    raise TypeError(\"Use IndexClass.from_documents(documents) instead\")","typeGuard":"def is_document_list(items) -> bool:\n    return bool(items) and isinstance(items[0], Document)","tryCatchPattern":null,"preventionTips":["Never pass Document objects in the nodes slot; Documents go to from_documents.","Pin to current llama-index APIs and purge pre-1.0 constructor patterns during upgrades."],"tags":["index","constructor","api-migration","validation","base-index"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}