{"record":{"id":"70d5ef7da056eafd","repo":"mem0ai/mem0","slug":"delete-failed-in-underlying-langchain-store-e","errorCode":null,"errorMessage":"Delete failed in underlying Langchain store: ${e}","messagePattern":"Delete failed in underlying Langchain store: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/langchain.ts","lineNumber":185,"sourceCode":"\n  async delete(vectorId: string): Promise<void> {\n    // Check if the underlying store supports deletion by ID\n    if (typeof (this.lcStore as any).delete === \"function\") {\n      try {\n        // We need to delete based on our stored _mem0_id.\n        // Langchain's delete often takes its own internal IDs or filter.\n        // Attempting deletion via filter is the most likely approach.\n        console.warn(\n          \"LangchainVectorStore: Attempting delete via filter on '_mem0_id'. Success depends on the specific Langchain VectorStore's delete implementation.\",\n        );\n        await (this.lcStore as any).delete({ filter: { _mem0_id: vectorId } });\n        // OR if it takes IDs directly (less common for *our* IDs):\n        // await (this.lcStore as any).delete({ ids: [vectorId] });\n      } catch (e) {\n        console.error(\n          `LangchainVectorStore: Delete failed. Underlying store's delete method might expect different arguments or filters. Error: ${e}`,\n        );\n        throw new Error(`Delete failed in underlying Langchain store: ${e}`);\n      }\n    } else {\n      console.error(\n        `LangchainVectorStore: The underlying Langchain store instance does not seem to support a 'delete' method.`,\n      );\n      throw new Error(\n        \"Method 'delete' not available on the provided Langchain VectorStore client.\",\n      );\n    }\n  }\n\n  async list(\n    filters?: SearchFilters,\n    topK: number = 100,\n  ): Promise<[VectorStoreResult[], number]> {\n    // No standard list method in Langchain core interface.\n    console.error(\n      `LangchainVectorStore: The 'list' method is not supported by the generic LangchainVectorStore wrapper.`,","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/langchain.ts#L167-L203","documentation":"delete() catches any exception from the underlying Langchain store's delete({ filter: { _mem0_id: vectorId } }) call and rethrows wrapped. The adapter guesses a filter-based delete signature because Langchain's delete API varies by implementation; if the store expects ids or a different filter shape, it throws and the wrapper surfaces it.","triggerScenarios":"Calling store.delete(id) when the underlying store's delete method has a different signature (e.g. expects { ids: [...] }), the filter field name differs, the store cannot filter on metadata during delete, or the store raises on missing permissions/not-found.","commonSituations":"Using community stores whose delete takes ids rather than a filter; the metadata key used for deletion not matching _mem0_id; store-side errors (connection loss, index missing) bubbling through delete.","solutions":["Read the underlying store's delete() signature; if it takes ids, call it directly: lcStore.delete({ ids: [vectorId] }) instead of the wrapper.","Ensure inserts actually store the mem0 id under the _mem0_id metadata key (the adapter does this; custom pipelines may not).","Inspect the wrapped error message — it contains the store's own reason (permissions, connectivity, not found).","Wrap delete in try-catch and treat 'not found' style errors as success if idempotency is desired."],"exampleFix":"// before\nawait store.delete(vectorId); // filter-based delete not supported by store\n\n// after\nconst lcStore = store.getUnderlyingStore?.() ?? lcStoreRef;\nawait lcStore.delete({ ids: [vectorId] });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await store.delete(vectorId);\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (msg.includes('Delete failed in underlying Langchain store')) {\n    // inspect inner message; if the store takes ids, call it directly:\n    // await lcStore.delete({ ids: [vectorId] });\n  }\n  throw e;\n}","preventionTips":["Read the underlying store's delete() signature before relying on the wrapper.","Ensure inserts store the mem0 id as _mem0_id metadata so filter-based delete can match.","Treat not-found deletes as idempotent success where appropriate."],"tags":["langchain","delete","wrapper","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}