{"record":{"id":"b37277f49c51bd35","repo":"langchain-ai/langchain","slug":"the-delete-operation-to-vectorstore-failed","errorCode":null,"errorMessage":"The delete operation to VectorStore failed.","messagePattern":"The delete operation to VectorStore failed\\.","errorType":"exception","errorClass":"IndexingException","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/indexing/api.py","lineNumber":266,"sourceCode":"    vector_store: VectorStore | DocumentIndex,\n    ids: list[str],\n) -> None:\n    \"\"\"Delete documents from a vector store or document index by their IDs.\n\n    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.\"\"\"","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/indexing/api.py#L248-L284","documentation":"Raised by the internal `_delete` helper in `langchain_core.indexing.api` during cleanup phases of `index()`. When the destination is a `VectorStore`, `VectorStore.delete(ids)` may return a success flag; a return value of exactly `False` (as opposed to None, which is treated as success) means the store itself reported the delete failed, and an `IndexingException` wraps that failure.","triggerScenarios":"Running `index(..., cleanup=\"full\"|\"incremental\"|\"scoped_full\")` where the vector store's `delete()` returns False — e.g. collection not found, IDs missing, or a store-side error swallowed into a boolean.","commonSituations":"Vector store collections deleted or renamed out-of-band; permission/network issues on the store that surface as False; custom VectorStore subclasses returning False on partial failure.","solutions":["Inspect the vector store directly (list/get the collection, run `store.delete([...])` manually) to find why it returns False.","Verify the collection name and that documents with those IDs exist before cleanup runs.","If you control the store subclass, return None on success or raise with detail instead of returning False."],"exampleFix":"# before (custom store)\nclass MyStore(VectorStore):\n    def delete(self, ids):\n        return self._http_delete(ids)  # False on any hiccup\n\n# after\nclass MyStore(VectorStore):\n    def delete(self, ids):\n        ok = self._http_delete(ids)\n        if not ok:\n            raise RuntimeError(f\"delete failed for ids={ids}\")\n        return True","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"from langchain_core.indexing.api import IndexingException  # conceptually\n# preflight: confirm delete works\nprobe_ids = [d.id for d in docs[:1]]\nok = store.delete(probe_ids)\nif ok is False:\n    raise RuntimeError(\"store.delete returned False; fix store before indexing\")","tryCatchPattern":"from langchain_core.indexing import IndexingException\n\ntry:\n    index(vs, docs, rm, cleanup=\"incremental\", source_id_key=\"source\")\nexcept IndexingException as e:\n    logger.error(\"Cleanup delete failed, store may be unhealthy: %s\", e)\n    alert_ops()  # do not blind-retry; inspect store first","preventionTips":["Health-check the vector store (list collection, sample delete) before scheduled cleanup runs.","If you own the store subclass, never return False silently — raise or return None."],"tags":["indexing","vector-store","cleanup","delete"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}