{"record":{"id":"1bffa613e99ef631","repo":"langchain-ai/langchain","slug":"add-texts-has-not-been-implemented-for-self-c","errorCode":null,"errorMessage":"`add_texts` has not been implemented for {self.__class__.__name__} ","messagePattern":"`add_texts` has not been implemented for (.+?) ","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/vectorstores/base.py","lineNumber":97,"sourceCode":"            if metadatas and len(metadatas) != len(texts_):\n                msg = (\n                    \"The number of metadatas must match the number of texts.\"\n                    f\"Got {len(metadatas)} metadatas and {len(texts_)} texts.\"\n                )\n                raise ValueError(msg)\n            metadatas_ = iter(metadatas) if metadatas else cycle([{}])\n            ids_: Iterator[str | None] = iter(ids) if ids else cycle([None])\n            docs = [\n                Document(id=id_, page_content=text, metadata=metadata_)\n                for text, metadata_, id_ in zip(texts, metadatas_, ids_, strict=False)\n            ]\n            if ids is not None:\n                # For backward compatibility\n                kwargs[\"ids\"] = ids\n\n            return self.add_documents(docs, **kwargs)\n        msg = f\"`add_texts` has not been implemented for {self.__class__.__name__} \"\n        raise NotImplementedError(msg)\n\n    @property\n    def embeddings(self) -> Embeddings | None:\n        \"\"\"Access the query embedding object if available.\"\"\"\n        logger.debug(\n            \"The embeddings property has not been implemented for %s\",\n            self.__class__.__name__,\n        )\n        return None\n\n    def delete(self, ids: list[str] | None = None, **kwargs: Any) -> bool | None:\n        \"\"\"Delete by vector ID or other criteria.\n\n        Args:\n            ids: List of IDs to delete. If `None`, delete all.\n            **kwargs: Other keyword arguments that subclasses might use.\n\n        Returns:","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/vectorstores/base.py#L79-L115","documentation":"`VectorStore.add_texts` is the abstract ingestion primitive in LangChain's vector store base class; when a subclass implements neither `add_texts` nor `add_documents`/`upsert`, the base implementation raises `NotImplementedError` naming the offending class. It signals the store cannot ingest data through this path at all.","triggerScenarios":"Calling `add_texts` (or a higher-level convenience like `VectorStore.from_documents`/`from_texts` that routes to it) on a custom `VectorStore` subclass that only implements read methods (`similarity_search`, etc.) or only `upsert` with a mismatched signature.","commonSituations":"Writing a read-only wrapper (e.g. over a pre-populated index) and accidentally hitting ingestion APIs; third-party store classes that subclass `VectorStore` for type compatibility without implementing writes; calling `from_texts` on such a store.","solutions":["Implement `add_texts` in your subclass (returning the list of assigned IDs), or implement `add_documents`/`upsert` so the shim can route.","If the store is read-only by design, guard call sites to never invoke ingestion APIs on it.","For third-party stores, check whether ingestion is exposed under a different method name and adapt."],"exampleFix":"# before\nclass MyStore(VectorStore):\n    def similarity_search(self, query, k=4, **kwargs):\n        return []\n\nstore.add_texts([\"a\"])  # NotImplementedError\n\n# after\nclass MyStore(VectorStore):\n    def add_texts(self, texts, metadatas=None, **kwargs):\n        return [self._insert(t, m) for t, m in zip(texts, metadatas or [{}] * len(texts))]\n\n    def similarity_search(self, query, k=4, **kwargs):\n        return []","handlingStrategy":"type-guard","validationCode":"from langchain_core.vectorstores import VectorStore\n\ndef supports_ingestion(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    )","typeGuard":"from langchain_core.vectorstores import VectorStore\n\ndef can_add_texts(store: VectorStore) -> bool:\n    \"\"\"True if the store implements an ingestion path.\"\"\"\n    return type(store).add_texts is not VectorStore.add_texts","tryCatchPattern":"try:\n    ids = store.add_texts(texts, metadatas)\nexcept NotImplementedError:\n    logger.warning(\"%s cannot ingest; skipping\", type(store).__name__)\n    ids = []","preventionTips":["Gate ingestion pipelines on `can_add_texts(store)`.","In custom stores, implement `add_texts` first — it is the minimal primitive everything else routes through.","Unit-test custom stores against the full base API you intend callers to use."],"tags":["vector-store","abstract-method","ingestion"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}