{"record":{"id":"c2da8e67db52eef8","repo":"langchain-ai/langchain","slug":"the-delete-operation-to-documentindex-failed","errorCode":null,"errorMessage":"The delete operation to DocumentIndex failed.","messagePattern":"The delete operation to DocumentIndex failed\\.","errorType":"exception","errorClass":"IndexingException","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/indexing/api.py","lineNumber":271,"sourceCode":"    Args:\n        vector_store: The vector store or document index to delete from.\n        ids: List of document IDs to delete.\n\n    Raises:\n        IndexingException: If the delete operation fails.\n        TypeError: If the `vector_store` is neither a `VectorStore` nor a\n            `DocumentIndex`.\n    \"\"\"\n    if isinstance(vector_store, VectorStore):\n        delete_ok = vector_store.delete(ids)\n        if delete_ok is not None and delete_ok is False:\n            msg = \"The delete operation to VectorStore failed.\"\n            raise IndexingException(msg)\n    elif isinstance(vector_store, DocumentIndex):\n        delete_response = vector_store.delete(ids)\n        if \"num_failed\" in delete_response and delete_response[\"num_failed\"] > 0:\n            msg = \"The delete operation to DocumentIndex failed.\"\n            raise IndexingException(msg)\n    else:\n        msg = (  # type: ignore[unreachable]\n            f\"Vectorstore should be either a VectorStore or a DocumentIndex. \"\n            f\"Got {type(vector_store)}.\"\n        )\n        raise TypeError(msg)\n\n\n# PUBLIC API\n\n\nclass IndexingResult(TypedDict):\n    \"\"\"Return a detailed a breakdown of the result of the indexing operation.\"\"\"\n\n    num_added: int\n    \"\"\"Number of added documents.\"\"\"\n    num_updated: int\n    \"\"\"Number of updated documents because they were not up to date.\"\"\"","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/indexing/api.py#L253-L289","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from langchain_core.indexing import IndexingException\nimport time\n\nfor attempt in range(3):\n    try:\n        index(doc_index, docs, rm, cleanup=\"full\")\n        break\n    except IndexingException as e:\n        if attempt == 2:\n            raise\n        time.sleep(2 ** attempt)  # backend transient delete failures often clear","preventionTips":["Indexing is idempotent/resumable — safe to re-run after fixing the backend.","Monitor DocumentIndex backend health and credential expiry before cleanup windows."],"tags":["indexing","document-index","cleanup","delete"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}