langchain-ai/langchain · error · ValueError
Vectorstore {destination} does not have required method {met
Error message
Vectorstore {destination} does not have required method {method} What it means
Raised in `index()` during preflight checks when the destination `VectorStore` lacks a method required for indexing. Cleanup and upserts rely on `delete` and `add_documents`; if the object subclasses `VectorStore` but does not expose one of those methods (usually because a poorly-written subclass overrode or removed it, or a lazy proxy hides attributes), indexing is aborted with a `ValueError` naming the store and the missing method.
Source
Thrown at libs/core/langchain_core/indexing/api.py:436
if (cleanup in {"incremental", "scoped_full"}) and source_id_key is None:
msg = (
"Source id key is required when cleanup mode is incremental or scoped_full."
)
raise ValueError(msg)
destination = vector_store # Renaming internally for clarity
# If it's a vectorstore, let's check if it has the required methods.
if isinstance(destination, VectorStore):
# Check that the Vectorstore has required methods implemented
methods = ["delete", "add_documents"]
for method in methods:
if not hasattr(destination, method):
msg = (
f"Vectorstore {destination} does not have required method {method}"
)
raise ValueError(msg)
if type(destination).delete == VectorStore.delete:
# Checking if the VectorStore has overridden the default delete method
# implementation which just raises a NotImplementedError
msg = "Vectorstore has not implemented the delete method"
raise ValueError(msg)
elif isinstance(destination, DocumentIndex):
pass
else:
msg = ( # type: ignore[unreachable]
f"Vectorstore should be either a VectorStore or a DocumentIndex. "
f"Got {type(destination)}."
)
raise TypeError(msg)
if isinstance(docs_source, BaseLoader):
try:
doc_iterator = docs_source.lazy_load()View on GitHub (pinned to e32fa9a52e)
Solutions
- Implement the missing method on your store subclass (`add_documents` and `delete` are both mandatory for indexing).
- Use `unittest.mock.create_autospec(VectorStore)` in tests so hasattr checks behave.
- For search-only stores, do not use the indexing API — insert documents with the store's native path.
Example fix
# before
class ReadOnlyStore(VectorStore):
# only similarity_search defined; no add_documents/delete
...
# after
class ReadOnlyStore(VectorStore):
def add_documents(self, documents, **kwargs):
self._client.upsert(...)
return [d.id for d in documents]
def delete(self, ids=None, **kwargs):
self._client.delete(ids)
return True Defensive patterns
Strategy: type-guard
Validate before calling
required = ("add_documents", "delete")
missing = [m for m in required if not hasattr(store, m)]
if missing:
raise TypeError(f"store lacks {missing}; cannot use indexing API")
index(store, docs, rm, cleanup="full") Type guard
def supports_indexing(store) -> bool:
return all(hasattr(store, m) for m in ("add_documents", "delete")) Prevention
- Implement the full required interface on custom VectorStore subclasses.
- Use create_autospec(VectorStore) for test doubles so hasattr preflights behave.
When it happens
Trigger: Passing a custom VectorStore subclass that implements similarity search but not `add_documents` or `delete`; using `__getattr__`-based lazy proxies whose `hasattr` behavior is broken; partially-mocked stores in tests.
Common situations: Read-only vector store wrappers (search-only proxy over an external service); homegrown stores implementing only the retrieval interface; Mock objects without speccing.
Related errors
- Vectorstore has not implemented the delete method
- The delete operation to VectorStore failed.
- Vectorstore should be either a VectorStore or a DocumentInde
- Vectorstore should be either a VectorStore or a DocumentInde
- Vectorstore has not implemented the adelete or delete method
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/801774e993bf87c7.
Report an issue: GitHub.