{"record":{"id":"0ac0204ff9d1d376","repo":"langchain-ai/langchain","slug":"add-documents-and-add-texts-has-not-been-imple","errorCode":null,"errorMessage":"`add_documents` and `add_texts` has not been implemented for {self.__class__.__name__} ","messagePattern":"`add_documents` and `add_texts` has not been implemented for (.+?) ","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/vectorstores/base.py","lineNumber":263,"sourceCode":"            List of IDs of the added texts.\n        \"\"\"\n        if type(self).add_texts != VectorStore.add_texts:\n            if \"ids\" not in kwargs:\n                ids = [doc.id for doc in documents]\n\n                # If there's at least one valid ID, we'll assume that IDs\n                # should be used.\n                if any(ids):\n                    kwargs[\"ids\"] = ids\n\n            texts = [doc.page_content for doc in documents]\n            metadatas = [doc.metadata for doc in documents]\n            return self.add_texts(texts, metadatas, **kwargs)\n        msg = (\n            f\"`add_documents` and `add_texts` has not been implemented \"\n            f\"for {self.__class__.__name__} \"\n        )\n        raise NotImplementedError(msg)\n\n    async def aadd_documents(\n        self, documents: list[Document], **kwargs: Any\n    ) -> list[str]:\n        \"\"\"Async run more documents through the embeddings and add to the `VectorStore`.\n\n        Args:\n            documents: Documents to add to the `VectorStore`.\n            **kwargs: Additional keyword arguments.\n\n        Returns:\n            List of IDs of the added texts.\n        \"\"\"\n        # If the async method has been overridden, we'll use that.\n        if type(self).aadd_texts != VectorStore.aadd_texts:\n            if \"ids\" not in kwargs:\n                ids = [doc.id for doc in documents]\n","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/vectorstores/base.py#L245-L281","documentation":"Raised by the base `VectorStore.add_documents` when the subclass implements neither `add_texts` nor `add_documents`/`upsert` override, meaning the store has no ingestion path at all. The message names both methods because the shim tries `add_texts` as the fallback primitive before giving up.","triggerScenarios":"Calling `add_documents(docs)` or `VectorStore.from_documents(docs, store)` on a custom subclass that only implements search/read methods; stores that subclass `VectorStore` purely for interface compliance.","commonSituations":"Read-only or externally-populated index wrappers; prototype subclasses where only `similarity_search` was written; helper utilities that blindly call `from_documents` on any `VectorStore` instance.","solutions":["Implement `add_texts` (preferred minimal primitive) or `add_documents`/`upsert` in the subclass.","If the store is populated externally (e.g. by a separate indexer), remove ingestion calls from your pipeline and load documents out-of-band.","Gate generic pipelines: only call `add_documents` when `type(store).add_texts is not VectorStore.add_texts`."],"exampleFix":"# before\nclass ReadOnlyStore(VectorStore):\n    def similarity_search(self, query, k=4, **kwargs):\n        return self._search(query, k)\n\nReadOnlyStore(...).add_documents(docs)  # NotImplementedError\n\n# after\nclass WritableStore(ReadOnlyStore):\n    def add_texts(self, texts, metadatas=None, **kwargs):\n        return self._backend.bulk_insert(texts, metadatas or [{}] * len(texts))","handlingStrategy":"type-guard","validationCode":"from langchain_core.vectorstores import VectorStore\n\ndef ingestion_ready(store: VectorStore) -> bool:\n    return (\n        type(store).add_texts is not VectorStore.add_texts\n        or type(store).add_documents is not VectorStore.add_documents\n    )\n\nif ingestion_ready(store):\n    ids = store.add_documents(docs)\nelse:\n    raise RuntimeError(f\"{type(store).__name__} is read-only; load documents externally\")","typeGuard":"from langchain_core.vectorstores import VectorStore\n\ndef can_add_documents(store: VectorStore) -> bool:\n    \"\"\"True if any ingestion path is implemented.\"\"\"\n    return (\n        type(store).add_texts is not VectorStore.add_texts\n        or type(store).add_documents is not VectorStore.add_documents\n    )","tryCatchPattern":"try:\n    ids = store.add_documents(docs)\nexcept NotImplementedError as e:\n    raise RuntimeError(\n        f\"Store {type(store).__name__} cannot ingest; populate it via its native loader\"\n    ) from e","preventionTips":["Feature-detect ingestion before calling `from_documents` helpers.","For externally-populated indexes, wrap them in a read-only façade that hides ingestion APIs.","When subclassing, implementing `add_texts` alone satisfies both `add_texts` and `add_documents`."],"tags":["vector-store","abstract-method","ingestion"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}