{"record":{"id":"39242cf245fb3902","repo":"mastra-ai/mastra","slug":"vectorstorename-is-required-got-vectorstorenam","errorCode":null,"errorMessage":"vectorStoreName is required, got: ${vectorStoreName}","messagePattern":"vectorStoreName is required, got: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/rag/src/tools/graph-rag.ts","lineNumber":53,"sourceCode":"  const inputSchema = options.enableFilter ? filterSchema : z.object(baseSchema).passthrough();\n\n  return createTool({\n    id: toolId,\n    inputSchema,\n    outputSchema,\n    description: toolDescription,\n    execute: async (inputData, context) => {\n      // See vector-query.ts for the same pattern: `context` from `createTool`\n      // is loosely typed; cast is safe because `createObservabilityContext`\n      // falls back to `noOpTracingContext` when `tracingContext` is undefined.\n      const { requestContext, mastra, tracingContext } = (context as any) || {};\n      const observabilityContext = createObservabilityContext(tracingContext);\n      const parentSpan = observabilityContext.tracingContext?.currentSpan;\n      const indexName: string = requestContext?.get('indexName') ?? options.indexName;\n      const vectorStoreName: string =\n        'vectorStore' in options ? storeName : (requestContext?.get('vectorStoreName') ?? storeName);\n      if (!indexName) throw new Error(`indexName is required, got: ${indexName}`);\n      if (!vectorStoreName) throw new Error(`vectorStoreName is required, got: ${vectorStoreName}`);\n      const includeSources: boolean = requestContext?.get('includeSources') ?? options.includeSources ?? true;\n      const randomWalkSteps: number | undefined =\n        requestContext?.get('randomWalkSteps') ?? graphOptions.randomWalkSteps;\n      const restartProb: number | undefined = requestContext?.get('restartProb') ?? graphOptions.restartProb;\n      const topK: number = requestContext?.get('topK') ?? (inputData.topK as number) ?? 10;\n      const filter: unknown = requestContext?.get('filter') ?? inputData.filter;\n      const queryText = inputData.queryText;\n      const providerOptions: ProviderOptions['providerOptions'] =\n        requestContext?.get('providerOptions') ?? options.providerOptions;\n\n      const enableFilter = !!requestContext?.get('filter') || (options.enableFilter ?? false);\n\n      const logger = mastra?.getLogger();\n      if (logger) {\n        logger.debug('[GraphRAGTool] execute called with:', { queryText, topK, filter });\n      }\n      try {\n        const topKValue = coerceTopK(topK);","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/rag/src/tools/graph-rag.ts#L35-L71","documentation":"createGraphRAGTool's execute resolves vectorStoreName from the configured store or requestContext; if it ends up empty it throws this error. The tool needs the name of a vector store registered on the Mastra instance to fetch it at runtime.","triggerScenarios":"Calling the tool when no vectorStore option is passed AND neither requestContext.get('vectorStoreName') nor the derived storeName is set; passing an empty string.","commonSituations":"Creating the tool without attaching it to a Mastra instance that has the vector registered; registerVector misspelled name mismatch; refactoring away the vectorStore option without supplying vectorStoreName.","solutions":["Pass a vectorStore option to createGraphRAGTool so storeName can be derived","Or register the vector on Mastra with a name and set vectorStoreName in options/requestContext","Ensure mastra.getVector(vectorStoreName) would find a store registered under exactly that name"],"exampleFix":"// before\nconst tool = createGraphRAGTool({ indexName: 'docs', model });\n// after\nconst tool = createGraphRAGTool({ vectorStore, indexName: 'docs', model });","handlingStrategy":"validation","validationCode":"const vectorStoreName = 'vectorStore' in options ? storeName : (requestContext?.get('vectorStoreName') ?? storeName);\nif (!vectorStoreName) throw new Error('createGraphRAGTool: vectorStoreName must be provided');","typeGuard":"const isNamedVector = (v: unknown): v is { name: string } => typeof v === 'object' && v !== null && typeof (v as any).name === 'string';","tryCatchPattern":"try { return await tool.execute(ctx); } catch (e) { if (e.message.startsWith('vectorStoreName is required')) { /* pass vectorStore or set vectorStoreName */ } else throw e; }","preventionTips":["Register the vector on the Mastra instance and reference it by the same name","When refactoring, keep vectorStore and vectorStoreName paths mutually consistent","Log mastra.getVector() availability for the expected name in smoke tests"],"tags":["configuration","validation","tool","graph-rag"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}