{"record":{"id":"9a36200662535902","repo":"mem0ai/mem0","slug":"either-memoryid-or-all-is-required-9a3620","errorCode":null,"errorMessage":"Either memoryId or --all is required","messagePattern":"Either memoryId or --all is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"integrations/openclaw/backend/platform.ts","lineNumber":263,"sourceCode":"    opts: DeleteOptions = {},\n  ): Promise<Record<string, unknown>> {\n    if (opts.all) {\n      const params: Record<string, string> = {};\n      if (opts.userId) params.user_id = opts.userId;\n      if (opts.agentId) params.agent_id = opts.agentId;\n      if (opts.appId) params.app_id = opts.appId;\n      if (opts.runId) params.run_id = opts.runId;\n      return (await this._request(\"DELETE\", \"/v1/memories/\", {\n        params,\n      })) as Record<string, unknown>;\n    }\n    if (memoryId) {\n      return (await this._request(\n        \"DELETE\",\n        `/v1/memories/${memoryId}/`,\n      )) as Record<string, unknown>;\n    }\n    throw new Error(\"Either memoryId or --all is required\");\n  }\n\n  async deleteEntities(opts: EntityIds): Promise<Record<string, unknown>> {\n    // v2 endpoint: DELETE /v2/entities/{entity_type}/{entity_id}/\n    const typeMap: [string, string | undefined][] = [\n      [\"user\", opts.userId],\n      [\"agent\", opts.agentId],\n      [\"app\", opts.appId],\n      [\"run\", opts.runId],\n    ];\n    const entities = typeMap.filter(([, v]) => v) as [string, string][];\n    if (entities.length === 0) {\n      throw new Error(\"At least one entity ID is required for deleteEntities.\");\n    }\n    // Delete each provided entity via the v2 path-based endpoint\n    let result: Record<string, unknown> = {};\n    for (const [entityType, entityId] of entities) {\n      result = (await this._request(","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/integrations/openclaw/backend/platform.ts#L245-L281","documentation":"Thrown by PlatformBackend.delete when neither a specific memoryId nor the --all/opts.all flag was supplied. The DELETE path needs either a single target (/v1/memories/{id}/) or filter parameters for a bulk delete (/v1/memories/?user_id=...), so the call is rejected before any network request is made.","triggerScenarios":"Calling backend.delete(undefined) or backend.delete() with opts.all unset; a CLI delete command invoked with no arguments and no --all flag; passing an empty-string memoryId (falsy) together with opts.all missing.","commonSituations":"CLI usage mistake (mem0 memory delete with no args); scripted deletion where the memoryId variable is undefined because an earlier search returned no results; agent tool invocation that omitted the id parameter.","solutions":["Pass a concrete memory id: backend.delete('m-uuid').","Or opt into bulk delete explicitly: backend.delete(undefined, { all: true, userId }) — note bulk delete requires filter params (user_id/app_id/run_id) on the platform endpoint.","If scripting, guard the call: skip deletion when the id is empty instead of calling delete()."],"exampleFix":"// before\nawait backend.delete(memoryId); // memoryId is undefined\n\n// after\nif (!memoryId && !opts.all) {\n  throw new Error('refusing to delete: no memoryId and no --all');\n}\nawait memoryId\n  ? backend.delete(memoryId)\n  : backend.delete(undefined, { all: true, userId });","handlingStrategy":"validation","validationCode":"function assertDeleteArgs(memoryId?: string, opts: { all?: boolean } = {}) {\n  if (!memoryId && !opts.all) {\n    throw new Error('refusing to call delete: pass a memoryId or { all: true }');\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await backend.delete(memoryId, opts);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Either memoryId or --all is required') {\n    // resolve an id via search() or re-run with { all: true }\n  } else throw err;\n}","preventionTips":["Only render a delete action in UIs when a memory row is selected.","Resolve ids from search/get_all results before offering deletion.","Treat empty-string ids as missing — they are falsy and trip this guard."],"tags":["validation","delete","platform-mode","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}