run-llama/llama_index · error · ValueError

The constructor now takes in a list of Node objects. Since y

Error message

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.

What it means

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.

Source

Thrown at llama-index-core/llama_index/core/indices/base.py:56

        self,
        nodes: Optional[Sequence[BaseNode]] = None,
        objects: Optional[Sequence[IndexNode]] = None,
        index_struct: Optional[IS] = None,
        storage_context: Optional[StorageContext] = None,
        callback_manager: Optional[CallbackManager] = None,
        transformations: Optional[List[TransformComponent]] = None,
        show_progress: bool = False,
        **kwargs: Any,
    ) -> None:
        """Initialize with parameters."""
        if index_struct is None and nodes is None and objects is None:
            raise ValueError("One of nodes, objects, or index_struct must be provided.")
        if index_struct is not None and nodes is not None and len(nodes) >= 1:
            raise ValueError("Only one of nodes or index_struct can be provided.")
        # This is to explicitly make sure that the old UX is not used
        if nodes is not None and len(nodes) >= 1 and not isinstance(nodes[0], BaseNode):
            if isinstance(nodes[0], Document):
                raise ValueError(
                    "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."
                )
            else:
                raise ValueError("nodes must be a list of Node objects.")

        self._storage_context = storage_context or StorageContext.from_defaults()
        self._docstore = self._storage_context.docstore
        self._show_progress = show_progress
        self._vector_store = self._storage_context.vector_store
        self._graph_store = self._storage_context.graph_store
        self._callback_manager = callback_manager or Settings.callback_manager

        objects = objects or []
        self._object_map = {obj.index_id: obj.obj for obj in objects}
        for obj in objects:
            obj.obj = None  # clear the object to avoid serialization issues

View on GitHub (pinned to afd0fef371)

Solutions

  1. Use the factory: VectorStoreIndex.from_documents(documents).
  2. If you already parsed documents into nodes yourself, pass those nodes: VectorStoreIndex(nodes=[TextNode(...), ...]).
  3. Check argument order — only Node objects (not Document) may appear in the nodes parameter.
  4. Transform documents to nodes explicitly via SentenceSplitter().get_nodes_from_documents(documents) if you need custom transformations.

Example fix

# before (old / wrong API)
index = VectorStoreIndex(documents)  # ValueError: use from_documents

# after
index = VectorStoreIndex.from_documents(documents)

# or with manual node control
from llama_index.core.node_parser import SentenceSplitter
nodes = SentenceSplitter().get_nodes_from_documents(documents)
index = VectorStoreIndex(nodes)
Defensive patterns

Strategy: validation

Validate before calling

from llama_index.core.schema import Document
if nodes and isinstance(nodes[0], Document):
    raise TypeError("Use IndexClass.from_documents(documents) instead")

Type guard

def is_document_list(items) -> bool:
    return bool(items) and isinstance(items[0], Document)

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/08963dfd0b0d2e00. Report an issue: GitHub.