{"record":{"id":"deb2ac24a3186d3e","repo":"mem0ai/mem0","slug":"at-least-one-filter-is-required-to-delete-all-memo","errorCode":null,"errorMessage":"At least one filter is required to delete all memories. If you want to delete all memories, use the `reset()` method.","messagePattern":"At least one filter is required to delete all memories\\. If you want to delete all memories, use the `reset\\(\\)` method\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/memory/index.ts","lineNumber":1738,"sourceCode":"  ): Promise<{ message: string }> {\n    await this._ensureInitialized();\n    await this._captureEvent(\"delete_all\", {\n      has_user_id: !!config.userId,\n      has_agent_id: !!config.agentId,\n      has_run_id: !!config.runId,\n    });\n    const userId = validateAndTrimEntityId(config.userId, \"userId\");\n    const agentId = validateAndTrimEntityId(config.agentId, \"agentId\");\n    const runId = validateAndTrimEntityId(config.runId, \"runId\");\n\n    // Convert camelCase entity params to snake_case for filters (matches storage and search/getAll)\n    const filters: SearchFilters = {};\n    if (userId) filters.user_id = userId;\n    if (agentId) filters.agent_id = agentId;\n    if (runId) filters.run_id = runId;\n\n    if (!Object.keys(filters).length) {\n      throw new Error(\n        \"At least one filter is required to delete all memories. If you want to delete all memories, use the `reset()` method.\",\n      );\n    }\n\n    let deletedCount = 0;\n    const seenBatches = new Set<string>();\n\n    while (true) {\n      const [batch] = await this.vectorStore.list(\n        filters,\n        DELETE_ALL_BATCH_SIZE,\n      );\n      if (!batch.length) {\n        break;\n      }\n      const batchKey = batch\n        .map((memory) => String(memory.id))\n        .sort()","sourceCodeStart":1720,"sourceCodeEnd":1756,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/memory/index.ts#L1720-L1756","documentation":"Thrown by Memory.deleteAll() when none of userId, agentId, or runId is provided in the config. Bulk deletion must be entity-scoped; the message explicitly points to reset() for the wipe-everything use case. The check runs after validateAndTrimEntityId normalizes the camelCase params, so whitespace-only IDs also end up here.","triggerScenarios":"Calling memory.deleteAll({}) or memory.deleteAll({ userId: '  ' }) — after trimming, filters is empty and Object.keys(filters).length === 0.","commonSituations":"Trying to clear the whole store for tests by calling deleteAll() with no args; passing entity IDs that are empty strings from an unset session; confusing deleteAll (scoped) with reset (global).","solutions":["Scope the deletion: memory.deleteAll({ userId: 'u1' })","To wipe everything (e.g. between test runs), call memory.reset() instead","If IDs come from session state, assert they are non-empty before calling"],"exampleFix":"// before\nawait memory.deleteAll({});\n\n// after\nawait memory.deleteAll({ userId: 'alice' });\n// or wipe everything:\nawait memory.reset();","handlingStrategy":"validation","validationCode":"if (!userId && !agentId && !runId) {\n  throw new Error('deleteAll requires a scope; use reset() to wipe everything');\n}\nawait memory.deleteAll({ userId, agentId, runId });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve reset() for test/seed scripts; production deletes should always carry a user/agent/run scope","Assert session entity IDs are non-empty strings before offering bulk delete"],"tags":["validation","oss","delete-all","destructive"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}