mem0ai/mem0 · error · Error
Failed to search vectors: ${error instanceof Error ? error.m
Error message
Failed to search vectors: ${error instanceof Error ? error.message : String(error)} What it means
Catch-all around Cloudflare Vectorize similarity search: any failure while querying the index (auth, missing index, network, malformed request) is logged and rethrown wrapped as 'Failed to search vectors: <message>'. The inner message carries the actual Cloudflare error text.
Source
Thrown at mem0-ts/src/oss/src/vector_stores/vectorize.ts:121
{
account_id: this.accountId,
vector: query,
filter: filters,
returnMetadata: "all",
topK: topK,
},
);
return (
(result?.matches?.map((match) => ({
id: match.id,
payload: match.metadata,
score: match.score,
})) as VectorStoreResult[]) || []
); // Return empty array if result or matches is null/undefined
} catch (error) {
console.error("Error searching vectors:", error);
throw new Error(
`Failed to search vectors: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
async get(vectorId: string): Promise<VectorStoreResult | null> {
await this.initialize();
try {
const result = (await this.client?.vectorize.indexes.getByIds(
this.indexName,
{
account_id: this.accountId,
ids: [vectorId],
},
)) as any;
if (!result?.length) return null;
View on GitHub (pinned to 001c235229)
Solutions
- Read the inner message and map it: 404 -> indexName/accountId wrong; 401 -> token; 400 dimension -> align embedding model with index dims.
- Verify the index exists: wrangler vectorize list, and compare with config indexName.
- For transient failures, retry the search — reads are idempotent.
Defensive patterns
Strategy: retry
Validate before calling
if (query.length !== indexDims) throw new Error(`Query vector is ${query.length} dims; index expects ${indexDims}`); Try / catch
try { return await memory.search(q, opts); } catch (e) { const m = e instanceof Error ? e.message : ''; if (m.startsWith('Failed to search vectors:')) { if (isTransientInner(m)) return retryWithBackoff(() => memory.search(q, opts), 3); throw new Error(m); } throw e; } Prevention
- Searches are read-only and safe to retry with backoff
- Validate query embedding dimension before search
- Cache the index metadata (dims) at startup
When it happens
Trigger: memory.search() against a deleted or renamed index; expired API token; account_id mismatch; dimension of the query vector differing from the index dims (Cloudflare rejects the query); network failure from the runtime.
Common situations: Index recreated after a config change while old code still references the prior indexName; token permissions narrowed to write-only; embeddings model changed without recreating the index.
Related errors
- Failed to insert vectors: ${error instanceof Error ? error.m
- Failed to update vector: ${error instanceof Error ? error.me
- Failed to insert vectors: ${response.status} ${errorText}
- Failed to get vector: ${error instanceof Error ? error.messa
- Failed to update vector: ${response.status} ${errorText}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/f67c5fcade97bd45.
Report an issue: GitHub.