mem0ai/mem0 · warning · Error
No entities to delete
Error message
No entities to delete
What it means
In the delete-users flow, when no specific userId/agentId/appId/runId is supplied the client fetches all entities via this.users() and builds a deletion list; if that list is empty it throws 'No entities to delete' rather than making zero API calls and reporting success. This prevents callers from believing a bulk wipe happened when there was nothing (or an auth/tenant mismatch meant nothing visible) to wipe.
Source
Thrown at mem0-ts/src/client/mem0.ts:559
if (userId) {
to_delete = [{ type: "user", name: userId }];
} else if (agentId) {
to_delete = [{ type: "agent", name: agentId }];
} else if (appId) {
to_delete = [{ type: "app", name: appId }];
} else if (runId) {
to_delete = [{ type: "run", name: runId }];
} else {
const entities = await this.users();
to_delete = entities.results.map((entity) => ({
type: entity.type,
name: entity.name,
}));
}
if (to_delete.length === 0) {
throw new Error("No entities to delete");
}
for (const entity of to_delete) {
try {
// fetch() reuses the pooled connection; axios here defaulted to
// keepAlive: false, one handshake per entity.
await this._fetchWithErrorHandling(
`${this.host}/v2/entities/${encodePathSegment(entity.type)}/${encodePathSegment(entity.name)}/`,
{
method: "DELETE",
headers: this.headers,
},
);
} catch (error: any) {
throw new APIError(
`Failed to delete ${entity.type} ${entity.name}: ${error.message}`,
);
}View on GitHub (pinned to 001c235229)
Solutions
- If empty is acceptable, treat the error as a no-op: check the users list first and skip when empty.
- Pass an explicit scope to avoid the bulk path: client.deleteUsers({ userId: 'alice' }).
- Verify you are pointed at the right host/org — call client.users() and inspect the results before bulk delete.
Example fix
// before
await client.deleteUsers({}); // throws 'No entities to delete' on empty workspace
// after
const { results } = await client.users();
if (results.length > 0) {
await client.deleteUsers({});
} Defensive patterns
Strategy: validation
Validate before calling
const users = await client.users();
if (users.results.length === 0) {
console.log('No entities to delete — skipping bulk delete');
} else {
await client.deleteUsers({});
} Type guard
const hasEntities = (r: { results: Array<{ type: string; name: string }> }): boolean => r.results.length > 0; Try / catch
try {
await client.deleteUsers({});
} catch (e) {
if ((e as Error).message === 'No entities to delete') return { deleted: 0 }; // benign empty state
throw e;
} Prevention
- Check users() count before any unscoped bulk delete.
- Prefer scoped deletes (userId/agentId/appId/runId) over the wipe-all path.
- Assert you are pointed at the intended environment before destructive bulk operations.
When it happens
Trigger: await client.deleteUsers({}) (or all-undefined scope) on an account/project whose users() call returns zero results — brand-new workspace, wrong org context, or an API key scoped to an empty project.
Common situations: Cleanup scripts run against the wrong environment; tests expecting seeded users that were never seeded; assuming entities exist without verifying; key scoped to a fresh project.
Related errors
- Failed to delete ${entity.type} ${entity.name}: ${error.mess
- Either memoryId or --all is required
- Either memoryId or all is required
- Delete failed for document ${vectorId}: ${result.errorMessag
- Delete failed in underlying Langchain store: ${e}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/1ad001e2386cd973.
Report an issue: GitHub.