{"record":{"id":"f842b514e3b33be6","repo":"mastra-ai/mastra","slug":"tried-to-upsert-embeddings-but-this-memory-instanc","errorCode":null,"errorMessage":"Tried to upsert embeddings but this Memory instance doesn't have an attached vector db.","messagePattern":"Tried to upsert embeddings but this Memory instance doesn't have an attached vector db\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/index.ts","lineNumber":1468,"sourceCode":"              embeddings: result.embeddings,\n              metadata: result.chunks.map(() => ({\n                ...threadMetadata,\n                message_id: message.id,\n                thread_id: message.threadId,\n                resource_id: message.resourceId,\n                role: message.role,\n                content: textForEmbedding,\n                created_at:\n                  message.createdAt instanceof Date ? message.createdAt.toISOString() : String(message.createdAt),\n              })),\n            });\n          }),\n        );\n\n        // Batch all vectors into a single upsert call to avoid pool exhaustion\n        if (embeddingData.length > 0 && dimension !== undefined) {\n          if (typeof this.vector === `undefined`) {\n            throw new Error(`Tried to upsert embeddings but this Memory instance doesn't have an attached vector db.`);\n          }\n\n          const { indexName } = await this.createEmbeddingIndex(dimension, config);\n\n          // Flatten all embeddings and metadata into single arrays\n          const allVectors: number[][] = [];\n          const allMetadata: Array<\n            Record<string, unknown> & {\n              message_id: string;\n              thread_id: string | undefined;\n              resource_id: string | undefined;\n            }\n          > = [];\n\n          for (const data of embeddingData) {\n            allVectors.push(...data.embeddings);\n            allMetadata.push(...data.metadata);\n          }","sourceCodeStart":1450,"sourceCodeEnd":1486,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/index.ts#L1450-L1486","documentation":"After generating embeddings for semantic recall, Memory upserts them into a vector store. If this.vector is undefined — i.e. no vector DB was passed to the Memory constructor — the upsert throws. Storage alone holds messages; the vector store is a separate, required dependency for semantic recall writes.","triggerScenarios":"Calling remember() (which saves message embeddings) with a Memory configured with storage and embedder but no vector store in the options.","commonSituations":"Using Memory({ storage, embedder }) and expecting embeddings to live in the relational store; omitting the vector option when migrating from a setup where it was provided; config objects built conditionally dropping vector.","solutions":["Attach a vector store: new Memory({ storage, embedder, vector: new LibSQLVector({ connectionUrl: ... }) }) (or PgVector, etc.).","If you don't want semantic recall, disable semanticRecall in the Memory config so no vector writes occur.","Check that your config builder actually includes the vector option rather than only storage/embedder."],"exampleFix":"// before\nconst memory = new Memory({ storage, embedder: new FastEmbed() });\n// after\nimport { LibSQLVector } from '@mastra/libsql';\nconst memory = new Memory({ storage, embedder: new FastEmbed(), vector: new LibSQLVector({ connectionUrl: 'file:./vectors.db' }) });","handlingStrategy":"validation","validationCode":"if (!memoryConfig.vector) {\n  throw new Error('Memory requires a vector store for semantic recall embedding writes');\n}\nconst memory = new Memory({ storage, embedder, vector: memoryConfig.vector });","typeGuard":"function hasVector(m: Memory): boolean {\n  return typeof (m as unknown as { vector?: unknown }).vector !== 'undefined';\n}","tryCatchPattern":"try {\n  await memory.remember({ threadId, resourceId, messages });\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"doesn't have an attached vector db\")) {\n    console.error('Configure a vector store (e.g. LibSQLVector) on the Memory instance.');\n  }\n  throw e;\n}","preventionTips":["Pass vector alongside storage and embedder whenever semanticRecall is enabled.","Use a single Memory factory that enforces the storage+embedder+vector trio.","Disable semanticRecall explicitly if your setup intentionally has no vector DB."],"tags":["memory","vector-store","embeddings","configuration"],"backgroundTag":"missing-vector-store","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}