{"record":{"id":"f0539e2e9d4e24a0","repo":"mem0ai/mem0","slug":"collectionname-is-required","errorCode":null,"errorMessage":"collectionName is required","messagePattern":"collectionName is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"mem0-ts/src/oss/src/vector_stores/s3_vectors.ts","lineNumber":52,"sourceCode":"\nexport class S3Vectors implements VectorStore {\n  private readonly config: S3VectorsConfig;\n  private readonly vectorBucketName: string;\n  private readonly collectionName: string;\n  private readonly dimension: number;\n  private readonly distanceMetric: \"cosine\" | \"euclidean\";\n  private client?: S3VectorsClientLike;\n  private clientPromise?: Promise<S3VectorsClientLike>;\n  private sdkPromise?: Promise<any>;\n  private _initPromise?: Promise<void>;\n  private cachedUserId?: string;\n\n  constructor(config: S3VectorsConfig) {\n    if (!config.vectorBucketName) {\n      throw new Error(\"vectorBucketName is required\");\n    }\n    if (!config.collectionName) {\n      throw new Error(\"collectionName is required\");\n    }\n\n    const dimension = config.embeddingModelDims ?? config.dimension;\n    if (!dimension || dimension < 1) {\n      throw new Error(\"embeddingModelDims or dimension is required\");\n    }\n\n    this.config = config;\n    this.vectorBucketName = config.vectorBucketName;\n    this.collectionName = config.collectionName;\n    this.dimension = dimension;\n    this.distanceMetric = config.distanceMetric || \"cosine\";\n\n    void this.initialize().catch(console.error);\n  }\n\n  /**\n   * Lazily import the optional `@aws-sdk/client-s3vectors` peer so consumers","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/s3_vectors.ts#L34-L70","documentation":"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.","triggerScenarios":"new S3Vectors({ vectorBucketName: 'b', dimension: 1536 }) with no collectionName; undefined collectionName from a config object built conditionally; env var for the collection name missing.","commonSituations":"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.","solutions":["Provide collectionName explicitly, e.g. collectionName: 'memories'","If deriving per-tenant names, default or validate the derived value before construction","Create the collection first (or rely on the store's create flow) and use the same name consistently"],"exampleFix":"// before\nconst vs = new S3Vectors({ vectorBucketName: 'b', dimension: 1536 });\n\n// after\nconst vs = new S3Vectors({ vectorBucketName: 'b', collectionName: 'memories', dimension: 1536 });","handlingStrategy":"validation","validationCode":"function assertS3VectorsConfig(c: any): void {\n  if (!c?.vectorBucketName) throw new Error('vectorBucketName is required');\n  if (!c?.collectionName) throw new Error('collectionName is required');\n}\nassertS3VectorsConfig(config);","typeGuard":"const hasCollection = (c: any): c is { collectionName: string } =>\n  typeof c?.collectionName === 'string' && c.collectionName.length > 0;","tryCatchPattern":"try { const vs = new S3Vectors(config); } catch (e) { if (e instanceof Error && e.message === 'collectionName is required') { /* supply collection name, not retryable */ } throw e; }","preventionTips":["Define collection names as constants shared across services","Validate derived/tenant collection names for emptiness before constructing the store","Type the config object so required fields are compile-time enforced"],"tags":["s3-vectors","aws","configuration","collection","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}