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

  1. Use array form for $or/OR branches: { $or: [{...}, {...}] }.
  2. Add a shared helper that constructs compound filters so the array shape is enforced in one place.
  3. 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

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


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/457fa64e15da5fff. Report an issue: GitHub.