mem0ai/mem0 · critical · Error

Vector operations failed. Please ensure: 1. The vector…

Error message

Vector operations failed. Please ensure:
1. The vector extension is enabled
2. The table "${this.tableName}" exists with correct schema
3. The match_vectors function is created
4. Row Level Security policies allow the configured Supabase key to read the table

RUN THE FOLLOWING SQL IN YOUR SUPABASE SQL EDITOR:

-- Enable the vector extension
create extension if not exists vector;

-- Create the memories table
create table if not exists memories (
  id text primary key,
  embedding vector(1536),
  metadata jsonb,
  created_at timestamp with time zone default timezone('utc', now()),
  updated_at timestamp with time zone default timezone('utc', now())
);

-- Create the memory migrations table
create table if not exists memory_migrations (
  user_id text primary key,
  created_at timestamp with time zone default timezone('utc', now())
);

-- Create the vector similarity search function
create or replace function match_vectors(
  query_embedding vector(1536),
  match_count int,
  filter jsonb default '{}'::jsonb
)
returns table (
  id text,
  similarity float,
  metadata jsonb
)
language plpgsql
as $$
begin
  return query
  select
    t.id::text,
    1 - (t.embedding <=> query_embedding) as similarity,
    t.metadata
  from memories t
  where case
    when filter::text = '{}'::text then true
    else t.metadata @> filter
  end
  order by t.embedding <=> query_embedding
  limit match_count;
end;
$$;

See the SQL migration instructions in the code comments.

What it means

During initialization, the Supabase vector store probes the configured table with a one-row select on the embedding column. If Supabase returns an error (missing table, missing vector extension, RLS blocking the key, wrong column), the store throws this aggregate error with ready-to-run SQL that creates the memories table, memory_migrations table, and match_vectors similarity function. It is a setup/diagnostic error, not a transient failure.

Solutions

  1. Open the Supabase SQL editor and run the exact SQL block embedded in the error message (extension, tables, match_vectors function).
  2. Verify the API key has access: either use the service_role key or add RLS SELECT policies for the authenticated/anon role on the table.
  3. Check config.tableName and the embedding column name match your actual schema (default 'memories' / 'embedding', vector(1536)).
  4. Adjust the vector(1536) literal in the SQL if your embedding model outputs a different dimension, then recreate.

Example fix

-- run in Supabase SQL editor (from the error message)
create extension if not exists vector;
create table if not exists memories (
  id text primary key,
  embedding vector(1536),
  metadata jsonb,
  created_at timestamptz default timezone('utc', now()),
  updated_at timestamptz default timezone('utc', now())
);
-- plus memory_migrations table and match_vectors function from the error text
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight: verify table probe succeeds before creating Memory
const { createClient } = await import('@supabase/supabase-js');
const sb = createClient(url, key);
const { error } = await sb.from('memories').select('embedding').limit(1);
if (error) throw new Error(`Supabase not ready — run the setup SQL first: ${error.message}`);

Try / catch

try { const memory = new Memory({ vectorStore: { provider: 'supabase', config } }); } catch (e) { if (e instanceof Error && e.message.includes('RUN THE FOLLOWING SQL')) { await runMigrations(); /* then retry construction */ } else throw e; }

Prevention

When it happens

Trigger: First use of the Supabase vector store against a fresh Supabase project where the vector extension, memories table, or match_vectors function does not exist; using an anon key whose RLS policies deny SELECT on the table; renaming tableName or embeddingColumnName in config to values that don't exist in the schema.

Common situations: New Supabase project without migrations applied; using service-role vs anon key with restrictive RLS; config.tableName pointing at a custom table that was never created; pgvector extension disabled on the project.

Related errors


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

Appendix: source

Thrown at mem0-ts/src/oss/src/vector_stores/supabase.ts:135

  async initialize(): Promise<void> {
    if (!this._initPromise) {
      this._initPromise = this._doInitialize();
    }
    return this._initPromise;
  }

  private async _doInitialize(): Promise<void> {
    await this.ensureClient();
    try {
      const { error: probeError } = await this.client
        .from(this.tableName)
        .select(this.embeddingColumnName)
        .limit(1);

      if (probeError) {
        console.error("Table probe error:", probeError);
        throw new Error(
          `Vector operations failed. Please ensure:
1. The vector extension is enabled
2. The table "${this.tableName}" exists with correct schema
3. The match_vectors function is created
4. Row Level Security policies allow the configured Supabase key to read the table

RUN THE FOLLOWING SQL IN YOUR SUPABASE SQL EDITOR:

-- Enable the vector extension
create extension if not exists vector;

-- Create the memories table
create table if not exists memories (
  id text primary key,
  embedding vector(1536),
  metadata jsonb,
  created_at timestamp with time zone default timezone('utc', now()),
  updated_at timestamp with time zone default timezone('utc', now())

View on GitHub (pinned to 001c235229)