{"record":{"id":"6885fa0a7302b4da","repo":"mastra-ai/mastra","slug":"tried-to-query-vector-index-indexname-but-this","errorCode":null,"errorMessage":"Tried to query vector index ${indexName} but this Memory instance doesn't have an attached vector db.","messagePattern":"Tried to query vector index (.+?) 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":738,"sourceCode":"          total: 0,\n          page: page ?? 0,\n          perPage: 0,\n          hasMore: false,\n        };\n        span?.end({ output: { success: true }, attributes: { messageCount: 0 } });\n        return result;\n      }\n\n      if (config?.semanticRecall && vectorSearchString && this.vector) {\n        const result = await this.embedMessageContent(vectorSearchString!);\n        usage = result.usage;\n        const { embeddings, dimension } = result;\n        const { indexName } = await this.createEmbeddingIndex(dimension, config);\n\n        await Promise.all(\n          embeddings.map(async embedding => {\n            if (typeof this.vector === `undefined`) {\n              throw new Error(\n                `Tried to query vector index ${indexName} but this Memory instance doesn't have an attached vector db.`,\n              );\n            }\n\n            const scopeFilter = resourceScope ? { resource_id: resourceId } : { thread_id: threadId };\n            const userFilter = typeof config.semanticRecall === 'object' ? config.semanticRecall.filter : undefined;\n            const combinedFilter = userFilter ? { $and: [scopeFilter, userFilter] } : scopeFilter;\n\n            vectorResults.push(\n              ...(await this.vector.query({\n                indexName,\n                queryVector: embedding,\n                topK: vectorConfig.topK,\n                filter: combinedFilter,\n              })),\n            );\n          }),\n        );","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/index.ts#L720-L756","documentation":"During recall's semantic search the embeddings are queried against a vector index, but the Memory instance has no vector store attached (this.vector undefined). The error is thrown defensively right before querying, naming the index that would have been used.","triggerScenarios":"Configuring semanticRecall without providing a `vector` option to `new Memory({...})`, then triggering a vector search; vector store constructor failing silently or being conditionally omitted (e.g. missing env vars for the provider).","commonSituations":"Copying Memory config examples without the vector field; vector store disabled when an API key env var is absent; switching storage backends that bundle a vector store to one that doesn't.","solutions":["Attach a vector store: pass `vector: new PGVector(...)`, `new FastVector(...)`, etc. when constructing Memory","Ensure the conditional that creates the vector store actually runs (check env vars/feature flags)","Disable semanticRecall if vector search is not intended"],"exampleFix":"// before\nconst memory = new Memory({ storage: store, embedder: embedder });\n// after\nimport { PGVector } from '@mastra/pg';\nconst memory = new Memory({ storage: store, embedder: embedder, vector: new PGVector({ connectionString: process.env.DATABASE_URL }) });","handlingStrategy":"validation","validationCode":"if (!memoryVector) throw new Error('Memory requires a vector store for semanticRecall; pass vector: new ...Vector(...)');","typeGuard":"function hasVectorStore(m: { vector?: unknown }): boolean {\n  return m.vector !== undefined && m.vector !== null;\n}","tryCatchPattern":null,"preventionTips":["Always construct Memory with a vector store when semanticRecall is enabled","Verify vector store construction errors/env vars at startup, not first recall","Add a startup assertion that memory.vector is defined when using semantic recall"],"tags":["memory","vector-store","configuration","semantic-recall"],"backgroundTag":"missing-vector-store","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}