mem0ai/mem0 · error · Error

Missing filters or schema

Error message

Missing filters or schema

What it means

Thrown by MemoryClient.createMemoryExport() when the payload lacks either filters or schema. Both are required by the POST /v1/exports/ endpoint: filters select which memories to export and schema defines the output shape. The SDK validates synchronously so you get a clear local error instead of a 400 from the API. Note filters and schema are passed through verbatim (no camelCase->snake_case key conversion) per issue #5593.

Source

Thrown at mem0-ts/src/client/mem0.ts:764

    this._captureEvent("feedback", [payloadKeys]);
    const response = await this._fetchWithErrorHandling(
      `${this.host}/v1/feedback/`,
      {
        method: "POST",
        headers: this.headers,
        body: JSON.stringify(camelToSnakeKeys(data)),
      },
    );
    return response;
  }

  async createMemoryExport(
    data: CreateMemoryExportPayload,
  ): Promise<{ message: string; id: string }> {
    this._captureEvent("create_memory_export", []);

    if (!data.filters || !data.schema) {
      throw new Error("Missing filters or schema");
    }

    // filters and schema are user-controlled blobs whose keys must reach the
    // API verbatim; only the remaining SDK params (e.g. exportInstructions)
    // get camel->snake conversion. See issue #5593.
    const { filters, schema, ...rest } = data;
    const response = await this._fetchWithErrorHandling(
      `${this.host}/v1/exports/`,
      {
        method: "POST",
        headers: this.headers,
        body: JSON.stringify({
          ...camelToSnakeKeys(rest),
          filters,
          schema,
        }),
      },
    );

View on GitHub (pinned to 001c235229)

Solutions

  1. Supply both fields: await client.createMemoryExport({ filters: { user_id: 'u1' }, schema: { type: 'object', properties: {...} } })
  2. Check the CreateMemoryExportPayload type — both filters and schema are non-optional; let the compiler catch the omission by typing your payload variable
  3. Keep filter/schema keys exactly as the API expects — they are NOT key-converted, so snake_case inside these blobs is preserved verbatim

Example fix

// before
await client.createMemoryExport({ filters: { userId: 'u1' } } as any);

// after
await client.createMemoryExport({
  filters: { user_id: 'u1' },
  schema: {
    type: 'object',
    properties: { memory: { type: 'string' } },
  },
});
Defensive patterns

Strategy: type-guard

Validate before calling

if (!payload.filters || typeof payload.filters !== 'object') throw new Error('filters required');
if (!payload.schema || typeof payload.schema !== 'object') throw new Error('schema required');
await client.createMemoryExport(payload);

Type guard

import type { CreateMemoryExportPayload } from 'mem0ai/oss';
const isCreateExportPayload = (
  p: Partial<CreateMemoryExportPayload>,
): p is CreateMemoryExportPayload =>
  !!p.filters && typeof p.filters === 'object' &&
  !!p.schema && typeof p.schema === 'object';

Try / catch

try {
  const { id } = await client.createMemoryExport(payload);
} catch (e) {
  if (e instanceof Error && e.message === 'Missing filters or schema') {
    // local validation failure — fix payload construction, do not retry as-is
    throw new Error('Export payload incomplete: build both filters and schema');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling createMemoryExport({ filters: {...} }) with no schema, or ({ schema: {...} }) with no filters, or passing an empty object / undefined for either field. Also hit when constructing the payload from a variable that is conditionally populated (e.g. filters only set in one branch).

Common situations: Copying a partial example from docs; assuming schema has a server-side default; passing snake_cased payload keys that TypeScript did not catch because the object was built as any.

Related errors


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