langchain-ai/langchain · error · IndexingException
The delete operation to DocumentIndex failed.
Error message
The delete operation to DocumentIndex failed.
What it means
Raised by `_delete` in `langchain_core.indexing.api` when the destination is a `DocumentIndex` rather than a `VectorStore`. `DocumentIndex.delete(ids)` returns a dict response; if it contains `"num_failed"` greater than zero, some deletions failed on the index side and an `IndexingException` is raised during indexing cleanup.
Source
Thrown at libs/core/langchain_core/indexing/api.py:271
Args:
vector_store: The vector store or document index to delete from.
ids: List of document IDs to delete.
Raises:
IndexingException: If the delete operation fails.
TypeError: If the `vector_store` is neither a `VectorStore` nor a
`DocumentIndex`.
"""
if isinstance(vector_store, VectorStore):
delete_ok = vector_store.delete(ids)
if delete_ok is not None and delete_ok is False:
msg = "The delete operation to VectorStore failed."
raise IndexingException(msg)
elif isinstance(vector_store, DocumentIndex):
delete_response = vector_store.delete(ids)
if "num_failed" in delete_response and delete_response["num_failed"] > 0:
msg = "The delete operation to DocumentIndex failed."
raise IndexingException(msg)
else:
msg = ( # type: ignore[unreachable]
f"Vectorstore should be either a VectorStore or a DocumentIndex. "
f"Got {type(vector_store)}."
)
raise TypeError(msg)
# PUBLIC API
class IndexingResult(TypedDict):
"""Return a detailed a breakdown of the result of the indexing operation."""
num_added: int
"""Number of added documents."""
num_updated: int
"""Number of updated documents because they were not up to date."""View on GitHub (pinned to e32fa9a52e)
Solutions
- Check the DocumentIndex backend logs/health for why deletes failed and retry the indexing run — indexing is resumable.
- Verify connectivity and permissions to the DocumentIndex before running cleanup.
- If failures are caused by already-missing IDs, clear the record manager state (`record_manager.delete_finished_records()` style reset) so stale IDs are not chased.
Defensive patterns
Strategy: retry
Try / catch
from langchain_core.indexing import IndexingException
import time
for attempt in range(3):
try:
index(doc_index, docs, rm, cleanup="full")
break
except IndexingException as e:
if attempt == 2:
raise
time.sleep(2 ** attempt) # backend transient delete failures often clear Prevention
- Indexing is idempotent/resumable — safe to re-run after fixing the backend.
- Monitor DocumentIndex backend health and credential expiry before cleanup windows.
When it happens
Trigger: Running `index()` with a DocumentIndex destination (e.g. a docstore retriever index) during full/incremental cleanup, where the backend reports partial delete failures via `num_failed > 0` in its response dict.
Common situations: DocumentIndex backends with eventual consistency where immediate deletes report failures; deleted/expired credentials mid-run; IDs already gone causing the backend to count them as failed.
Related errors
- The delete operation to VectorStore failed.
- source_id_key should be either None, a string or a callable.
- cleanup should be one of 'incremental', 'full', 'scoped_full
- Source id key is required when cleanup mode is incremental o
- Vectorstore has not implemented the delete method
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/c2da8e67db52eef8.
Report an issue: GitHub.