mem0ai/mem0 · critical · Error

collectionName is required

Error message

collectionName is required

What it means

The S3 Vectors store requires a collection name (the index inside the vector bucket) at construction. It is the logical grouping of vectors, so a missing collectionName is a constructor-level configuration error caught immediately after the bucket check.

Source

Thrown at mem0-ts/src/oss/src/vector_stores/s3_vectors.ts:52

export class S3Vectors implements VectorStore {
  private readonly config: S3VectorsConfig;
  private readonly vectorBucketName: string;
  private readonly collectionName: string;
  private readonly dimension: number;
  private readonly distanceMetric: "cosine" | "euclidean";
  private client?: S3VectorsClientLike;
  private clientPromise?: Promise<S3VectorsClientLike>;
  private sdkPromise?: Promise<any>;
  private _initPromise?: Promise<void>;
  private cachedUserId?: string;

  constructor(config: S3VectorsConfig) {
    if (!config.vectorBucketName) {
      throw new Error("vectorBucketName is required");
    }
    if (!config.collectionName) {
      throw new Error("collectionName is required");
    }

    const dimension = config.embeddingModelDims ?? config.dimension;
    if (!dimension || dimension < 1) {
      throw new Error("embeddingModelDims or dimension is required");
    }

    this.config = config;
    this.vectorBucketName = config.vectorBucketName;
    this.collectionName = config.collectionName;
    this.dimension = dimension;
    this.distanceMetric = config.distanceMetric || "cosine";

    void this.initialize().catch(console.error);
  }

  /**
   * Lazily import the optional `@aws-sdk/client-s3vectors` peer so consumers

View on GitHub (pinned to 001c235229)

Solutions

  1. Provide collectionName explicitly, e.g. collectionName: 'memories'
  2. If deriving per-tenant names, default or validate the derived value before construction
  3. Create the collection first (or rely on the store's create flow) and use the same name consistently

Example fix

// before
const vs = new S3Vectors({ vectorBucketName: 'b', dimension: 1536 });

// after
const vs = new S3Vectors({ vectorBucketName: 'b', collectionName: 'memories', dimension: 1536 });
Defensive patterns

Strategy: validation

Validate before calling

function assertS3VectorsConfig(c: any): void {
  if (!c?.vectorBucketName) throw new Error('vectorBucketName is required');
  if (!c?.collectionName) throw new Error('collectionName is required');
}
assertS3VectorsConfig(config);

Type guard

const hasCollection = (c: any): c is { collectionName: string } =>
  typeof c?.collectionName === 'string' && c.collectionName.length > 0;

Try / catch

try { const vs = new S3Vectors(config); } catch (e) { if (e instanceof Error && e.message === 'collectionName is required') { /* supply collection name, not retryable */ } throw e; }

Prevention

When it happens

Trigger: new S3Vectors({ vectorBucketName: 'b', dimension: 1536 }) with no collectionName; undefined collectionName from a config object built conditionally; env var for the collection name missing.

Common situations: Config objects where collectionName is optional in user code but required by the store; renaming config fields and missing one call site; multi-tenant setups deriving the collection name where the derivation returns undefined.

Related errors


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