mem0ai/mem0 · error · Error
Failed to delete vector: ${error instanceof Error ? error.me
Error message
Failed to delete vector: ${error instanceof Error ? error.message : String(error)} What it means
Catch-all around Cloudflare Vectorize deleteByIds: deleting a vector by id failed and the error is rethrown wrapped as 'Failed to delete vector: <message>'. Missing ids do not error in Vectorize — this throw means the API call failed (auth, wrong index/account, network).
Source
Thrown at mem0-ts/src/oss/src/vector_stores/vectorize.ts:200
}
} catch (error) {
console.error("Error updating vector:", error);
throw new Error(
`Failed to update vector: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
async delete(vectorId: string): Promise<void> {
await this.initialize();
try {
await this.client?.vectorize.indexes.deleteByIds(this.indexName, {
account_id: this.accountId,
ids: [vectorId],
});
} catch (error) {
console.error("Error deleting vector:", error);
throw new Error(
`Failed to delete vector: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
async deleteCol(): Promise<void> {
await this.initialize();
try {
await this.client?.vectorize.indexes.delete(this.indexName, {
account_id: this.accountId,
});
} catch (error) {
console.error("Error deleting collection:", error);
throw new Error(
`Failed to delete collection: ${error instanceof Error ? error.message : String(error)}`,
);
}
}View on GitHub (pinned to 001c235229)
Solutions
- Check the inner message: 401/403 -> grant the token full Vectorize edit permission; 404 -> verify indexName and accountId.
- Retry transient network/5xx failures.
- If the goal is a full reset, deleteAll/deleteCol recreates state cleanly instead of per-id deletes.
Defensive patterns
Strategy: try-catch
Try / catch
try { await memory.delete(id); } catch (e) { const m = e instanceof Error ? e.message : ''; if (m.startsWith('Failed to delete vector:')) { if (isTransientInner(m)) await retryWithBackoff(() => memory.delete(id), 2); else throw new Error(`Vectorize delete failed: ${m}`); } else throw e; } Prevention
- Deleting a non-existent id does not throw — only API failures do
- Include delete scope in the token
- Use deleteAll for full resets instead of looping deletes
When it happens
Trigger: memory.delete(id) with a token lacking delete permission; indexName/accountId mismatch; Cloudflare API or network failure; the index having been purged/recreated.
Common situations: Least-privilege tokens missing the delete scope; stale indexName after recreation; transient 5xx.
Related errors
- Failed to get vector: ${error instanceof Error ? error.messa
- Failed to insert vectors: ${response.status} ${errorText}
- Failed to insert vectors: ${error instanceof Error ? error.m
- Failed to search vectors: ${error instanceof Error ? error.m
- Failed to update vector: ${response.status} ${errorText}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/d550e13231a72abd.
Report an issue: GitHub.