{"record":{"id":"e38c26ca92123bdd","repo":"langchain-ai/langchain","slug":"delete-method-must-be-implemented-by-subclass","errorCode":null,"errorMessage":"delete method must be implemented by subclass.","messagePattern":"delete method must be implemented by subclass\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/vectorstores/base.py","lineNumber":120,"sourceCode":"        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:\n            `True` if deletion is successful, `False` otherwise, `None` if not\n                implemented.\n        \"\"\"\n        msg = \"delete method must be implemented by subclass.\"\n        raise NotImplementedError(msg)\n\n    def get_by_ids(self, ids: Sequence[str], /) -> list[Document]:\n        \"\"\"Get documents by their IDs.\n\n        The returned documents are expected to have the ID field set to the ID of the\n        document in the vector store.\n\n        Fewer documents may be returned than requested if some IDs are not found or\n        if there are duplicated IDs.\n\n        Users should not assume that the order of the returned documents matches\n        the order of the input IDs. Instead, users should rely on the ID field of the\n        returned documents.\n\n        This method should **NOT** raise exceptions if no documents are found for\n        some IDs.\n\n        Args:","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/vectorstores/base.py#L102-L138","documentation":"The base `VectorStore.delete` raises `NotImplementedError` because deletion is optional for vector store integrations. Subclasses that support removal must override it; otherwise callers get this explicit error rather than a silent no-op that would leave stale data.","triggerScenarios":"Calling `vectorstore.delete(ids=[...])` on any store whose class does not override `delete` — including the base class itself and minimal custom subclasses.","commonSituations":"Generic cleanup pipelines (deleting documents by source or TTL) run against a store that never implemented deletion; assuming a standard-looking API exists on every integration; attempting document-refresh workflows (delete + re-add) on a read-optimized store.","solutions":["Check `type(store).delete is VectorStore.delete` before calling, and skip or branch to a store-specific deletion API.","Implement `delete` in your custom subclass mapping `ids` to the backend's removal endpoint.","For refresh workflows on stores without delete, re-ingest with stable explicit `ids` so upsert semantics replace content instead."],"exampleFix":"# before\nstore.delete(ids=[\"doc1\"])  # NotImplementedError\n\n# after\nif type(store).delete is not VectorStore.delete:\n    store.delete(ids=[\"doc1\"])\nelse:\n    logger.warning(\"store %s does not support delete\", type(store).__name__)","handlingStrategy":"type-guard","validationCode":"from langchain_core.vectorstores import VectorStore\n\ndef can_delete(store: VectorStore) -> bool:\n    return type(store).delete is not VectorStore.delete","typeGuard":"from langchain_core.vectorstores import VectorStore\n\ndef supports_delete(store: VectorStore) -> bool:\n    \"\"\"True if the store overrides the optional delete method.\"\"\"\n    return type(store).delete is not VectorStore.delete","tryCatchPattern":"try:\n    store.delete(ids=stale_ids)\nexcept NotImplementedError:\n    # fall back to re-ingesting with the same ids (upsert semantics)\n    store.add_texts(new_texts, new_metadatas, ids=stale_ids)","preventionTips":["Check `supports_delete(store)` before building delete-based refresh workflows.","Design refresh flows around stable explicit ids so upsert can replace delete where deletion is unsupported.","Document which optional `VectorStore` methods your integration implements."],"tags":["vector-store","abstract-method","deletion"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}