{"record":{"id":"54f6aadf8227b852","repo":"mem0ai/mem0","slug":"collectionname-is-required-for-upstash-vector","errorCode":null,"errorMessage":"collectionName is required for Upstash Vector.","messagePattern":"collectionName is required for Upstash Vector\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/upstash_vector.ts","lineNumber":24,"sourceCode":"interface UpstashVectorConfig extends VectorStoreConfig {\n  collectionName: string;\n  url?: string;\n  token?: string;\n  /** Pre-configured Upstash Vector client instance (typed as `any` to keep\n   *  the optional driver's types out of the published type declarations). */\n  client?: any;\n}\n\ntype UpstashMetadata = Record<string, unknown>;\n\nexport class UpstashVector implements VectorStore {\n  private client!: Index<UpstashMetadata>;\n  private readonly config: UpstashVectorConfig;\n  private readonly collectionName: string;\n\n  constructor(config: UpstashVectorConfig) {\n    if (!config.collectionName) {\n      throw new Error(\"collectionName is required for Upstash Vector.\");\n    }\n    if (!config.client && !(config.url && config.token)) {\n      throw new Error(\"Either a client or url and token must be provided.\");\n    }\n\n    this.config = config;\n    this.collectionName = config.collectionName;\n  }\n\n  /**\n   * Lazily construct (or reuse) the Upstash Vector client, importing the\n   * optional `@upstash/vector` peer only when the store is first used so\n   * consumers that never touch Upstash Vector don't need it installed.\n   */\n  private async ensureClient(): Promise<void> {\n    if (this.client) return;\n\n    const config = this.config;","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/upstash_vector.ts#L6-L42","documentation":"The Upstash Vector store requires a collection name because Upstash organizes vectors per index/collection. The constructor throws at instantiation if config.collectionName is missing or empty — no network call is attempted.","triggerScenarios":"new Memory({ vectorStore: { provider: 'upstash_vector', config: { url, token } } }) with no collectionName; passing collectionName: '' or undefined; copy-pasting config from another provider that has no collection concept.","commonSituations":"Migrating from a store without collections (e.g. pgvector with tableName); forgetting to create/name the Upstash index first; typos like collection_name or indexName in the config object.","solutions":["Create an index in the Upstash console and pass its name: config: { collectionName: 'memories', url, token }.","Double-check the exact key is collectionName (camelCase), not indexName or collection_name.","Set collectionName from an env var if it varies per environment (e.g. UPSTASH_COLLECTION)."],"exampleFix":"// before\nnew Memory({ vectorStore: { provider: 'upstash_vector', config: { url, token } } });\n\n// after\nnew Memory({ vectorStore: { provider: 'upstash_vector', config: { collectionName: 'memories', url, token } } });","handlingStrategy":"validation","validationCode":"if (!config?.collectionName) throw new Error('upstash_vector requires config.collectionName — create the index in the Upstash console first');","typeGuard":"const hasUpstashCollection = (cfg: { collectionName?: string }): cfg is { collectionName: string } => typeof cfg.collectionName === 'string' && cfg.collectionName.length > 0;","tryCatchPattern":"try { new Memory({ vectorStore: { provider: 'upstash_vector', config } }); } catch (e) { if (e instanceof Error && e.message.includes('collectionName is required')) { /* prompt for index name / read from env */ } else throw e; }","preventionTips":["Validate required config fields in one place before constructing Memory","Derive collectionName from env per environment"],"tags":["upstash","config","validation","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}