{"record":{"id":"cf41a45cef810233","repo":"mem0ai/mem0","slug":"delete-failed-for-document-vectorid-result-e","errorCode":null,"errorMessage":"Delete failed for document ${vectorId}: ${result.errorMessage}","messagePattern":"Delete failed for document (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/azure_ai_search.ts","lineNumber":459,"sourceCode":"        payload,\n      });\n    }\n\n    return results;\n  }\n\n  /**\n   * Delete a vector by ID\n   */\n  async delete(vectorId: string): Promise<void> {\n    await this.initialize();\n    const response = await this.searchClient.deleteDocuments([\n      { id: vectorId },\n    ]);\n\n    for (const result of response.results) {\n      if (!result.succeeded) {\n        throw new Error(\n          `Delete failed for document ${vectorId}: ${result.errorMessage}`,\n        );\n      }\n    }\n\n    console.log(\n      `Deleted document with ID '${vectorId}' from index '${this.indexName}'.`,\n    );\n  }\n\n  /**\n   * Update a vector and its payload\n   */\n  async update(\n    vectorId: string,\n    vector: number[],\n    payload: Record<string, any>,\n  ): Promise<void> {","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/azure_ai_search.ts#L441-L477","documentation":"delete(vectorId) calls deleteDocuments([{ id: vectorId }]) and then checks each per-document result; if result.succeeded is false it throws with the document id and Azure's errorMessage. Azure AI Search reports per-document outcomes even when the HTTP call succeeds, so a failed delete (e.g. wrong key type or index unavailable) surfaces here rather than as a rejected promise.","triggerScenarios":"memory.delete(id) on Azure AI Search when the index is being rebuilt/recreated; the id does not conform to the index key (e.g. characters Azure rejects for a key field); throttling during a delete batch.","commonSituations":"Deleting memories right after index recreation; ids sanitized differently than at insert time; transient 503s on a free-tier search service.","solutions":["Inspect errorMessage in the thrown message: for throttling, retry after a backoff.","Confirm the id being deleted is exactly the one returned at insert time (no trimming/sanitizing differences).","Verify the target index exists and is not in the middle of a rebuild."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await memory.delete(id) }\ncatch (e) {\n  if (e instanceof Error && /Delete failed for document/.test(e.message)) {\n    if (/throttl|503|busy/i.test(e.message)) { await sleep(2000); await memory.delete(id); }\n    else throw e;\n  } else throw e;\n}","preventionTips":["Delete using ids exactly as returned by search/add results.","Treat per-document delete failures as retryable for transient messages; non-transient ones usually mean the index schema/state changed.","Avoid interleaving index rebuilds with delete traffic."],"tags":["azure","vector-store","delete","partial-failure"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}