mem0ai/mem0 · error · Error

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

Error message

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

What it means

filterVector() throws when a NOT filter key holds a non-array value. NOT is evaluated as .every() over sub-filters that must each NOT match; a non-array value cannot be iterated and is rejected as a malformed filter.

Source

Thrown at mem0-ts/src/oss/src/vector_stores/databricks.ts:1609

        ) {
          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(
            (entry: SearchFilters) => !this.filterVector(vector, entry),
          )
        ) {
          return false;
        }
      } else if (!this.matchFieldCondition(vector, key, value)) {
        return false;
      }
    }

    return true;
  }
}

View on GitHub (pinned to 001c235229)

Solutions

  1. Wrap the negated filter(s) in an array: { NOT: [{ user_id: 'u1' }] }.
  2. Centralize filter construction in a small builder function that type-checks compound branches.
  3. Check the SearchFilters type docs for AND/OR/NOT array semantics.

Example fix

// before
store.search(query, 5, { NOT: { user_id: 'u1' } });

// after
store.search(query, 5, { NOT: [{ user_id: 'u1' }] });
Defensive patterns

Strategy: type-guard

Validate before calling

if ('NOT' in filters && !Array.isArray((filters as any).NOT)) {
  throw new Error('NOT branch must be an array of filter dicts');
}

Type guard

const isValidNotBranch = (f: unknown) =>
  !(typeof f === 'object' && f !== null && 'NOT' in f) || Array.isArray((f as any).NOT);

Try / catch

try {
  await store.search(q, k, filters);
} catch (e) {
  if (e instanceof Error && e.message.includes('NOT filter value must be a list')) {
    // wrap the NOT value in an array and retry
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling search()/list() with { NOT: { user_id: 'u1' } } instead of { NOT: [{ user_id: 'u1' }] }.

Common situations: Assuming NOT takes a single filter object (common convention elsewhere); filter builders emitting a bare object for negation; copy-paste from other vector store SDKs.

Related errors


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