mem0ai/mem0 · error · Error
OR filter value must be a list of filter dicts, got ${typeof
Error message
OR filter value must be a list of filter dicts, got ${typeof value} What it means
filterVector() throws when an OR filter key holds a non-array value. OR branches are evaluated with .some() over a list of sub-filter dicts; anything else (object, string, number) is a malformed filter and is rejected before evaluation rather than treated as a match/no-match.
Source
Thrown at mem0-ts/src/oss/src/vector_stores/databricks.ts:1596
}
for (const [key, value] of Object.entries(normalized)) {
if (key === "AND") {
if (!Array.isArray(value)) {
throw new Error(
`AND filter value must be a list of filter dicts, got ${typeof value}`,
);
}
if (
!value.every((entry: SearchFilters) =>
this.filterVector(vector, entry),
)
) {
return false;
}
} else if (key === "OR") {
if (!Array.isArray(value)) {
throw new Error(
`OR filter value must be a list of filter dicts, got ${typeof value}`,
);
}
if (
!value.some((entry: SearchFilters) =>
this.filterVector(vector, entry),
)
) {
return false;
}
} else if (key === "NOT") {
if (!Array.isArray(value)) {
throw new Error(
`NOT filter value must be a list of filter dicts, got ${typeof value}`,
);
}
if (
!value.every(View on GitHub (pinned to 001c235229)
Solutions
- Use array form for $or/OR branches: { $or: [{...}, {...}] }.
- Add a shared helper that constructs compound filters so the array shape is enforced in one place.
- Unit-test filter construction code against the expected shape.
Example fix
// before
store.search(query, 5, { OR: { user_id: 'u1' } });
// after
store.search(query, 5, { OR: [{ user_id: 'u1' }] }); Defensive patterns
Strategy: type-guard
Validate before calling
if ('OR' in filters && !Array.isArray((filters as any).OR)) {
throw new Error('OR branch must be an array of filter dicts');
} Type guard
const hasArrayBranches = (f: unknown): f is Record<string, unknown[]> =>
typeof f === 'object' && f !== null &&
Object.entries(f).every(([k, v]) =>
k === 'OR' || k === 'AND' || k === 'NOT' ? Array.isArray(v) : true,
); Try / catch
try {
await store.search(q, k, filters);
} catch (e) {
if (e instanceof Error && e.message.includes('OR filter value must be a list')) {
// normalize OR value to an array and retry
}
throw e;
} Prevention
- Treat $or/OR strictly as a list of sub-filter dicts.
- Use a shared typed filter builder instead of inline literals.
- Validate dynamically-built filters before passing them to search/list.
When it happens
Trigger: Calling search()/list() with { OR: { user_id: 'u1' } } or { $or: 'x' } instead of { OR: [{ user_id: 'u1' }, { user_id: 'u2' }] }.
Common situations: Hand-written filters copied from SQL intuitions ('OR' as a flat object); dynamic filter assembly that forgets the array wrapper; porting Python SDK examples where nesting differs.
Related errors
- AND filter value must be a list of filter dicts, got ${typeo
- NOT filter value must be a list of filter dicts, got ${typeo
- AND filter value must be a list of filter dicts, got ${typeo
- OR filter value must be a list of filter dicts, got ${typeof
- NOT filter value must be a list of filter dicts, got ${typeo
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/457fa64e15da5fff.
Report an issue: GitHub.