mem0ai/mem0 · error · Error

AND filter value must be a list of filter dicts, got ${typeo

Error message

AND filter value must be a list of filter dicts, got ${typeof value}

What it means

The Cassandra store filters vectors in memory via filterVector(). An 'AND' key must map to an array of filter objects so each entry can be evaluated and ANDed together. Passing an object (or any non-array) instead throws immediately with the offending JS type.

Source

Thrown at mem0-ts/src/oss/src/vector_stores/cassandra.ts:542

    }

    const keyMap: Record<string, string> = {
      $and: "AND",
      $or: "OR",
      $not: "NOT",
    };
    const normalized: Record<string, any> = {};
    for (const [key, value] of Object.entries(filters)) {
      const normalizedKey = keyMap[key] || key;
      if (!(normalizedKey in normalized)) {
        normalized[normalizedKey] = value;
      }
    }

    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) =>

View on GitHub (pinned to 001c235229)

Solutions

  1. Wrap the AND value in an array: { AND: [{ user_id: 'x' }, { run_id: 'y' }] }
  2. If a single condition, either put it at the top level ({ user_id: 'x' }) or wrap it as a one-element array

Example fix

// before
memory.search('query', { filters: { AND: { user_id: 'u1', run_id: 'r1' } } });

// after
memory.search('query', { filters: { AND: [{ user_id: 'u1' }, { run_id: 'r1' }] } });
Defensive patterns

Strategy: type-guard

Validate before calling

function isFilterDictArray(v: unknown): v is Record<string, any>[] {
  return Array.isArray(v) && v.every((e) => e && typeof e === 'object' && !Array.isArray(e));
}
if (filters.AND && !isFilterDictArray(filters.AND)) throw new Error('AND must be an array of filter dicts');

Type guard

const isFilterDictArray = (v: unknown): v is Record<string, any>[] =>
  Array.isArray(v) && v.every((e) => e !== null && typeof e === 'object' && !Array.isArray(e));

Prevention

When it happens

Trigger: Calling search/list/getAll with filters like { AND: { user_id: 'x' } } (a single dict) or { AND: 'user_id=x' } (a string) instead of { AND: [{ user_id: 'x' }, { run_id: 'y' }] }.

Common situations: Assuming AND takes a single combined object because other filter keys do; converting filters from another store's DSL where AND is an object; hand-building filters from dynamic code that collapses arrays.

Related errors


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