{"record":{"id":"400488e178d4f4e0","repo":"mastra-ai/mastra","slug":"indexname-is-required-got-indexname","errorCode":null,"errorMessage":"indexName is required, got: ${indexName}","messagePattern":"indexName is required, got: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/rag/src/tools/graph-rag.ts","lineNumber":52,"sourceCode":"\n  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 {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/rag/src/tools/graph-rag.ts#L34-L70","documentation":"createGraphRAGTool's execute resolves indexName from requestContext or tool options; if both are empty/undefined it throws this error naming the received value. A graph RAG query cannot run without knowing which vector index to search.","triggerScenarios":"Running the tool without options.indexName and without requestContext.get('indexName'); passing indexName: '' ; RequestContext overrides returning empty strings.","commonSituations":"Configuring the tool with only vectorStore/index but forgetting indexName; setting indexName via requestContext in a path that doesn't propagate it; renaming an index but leaving the old config blank.","solutions":["Pass indexName in createGraphRAGTool options: { vectorStore, indexName: 'my-index', ... }","If using requestContext, ensure the middleware sets 'indexName' before execute","Check the interpolated value in the message to see whether it was undefined or an empty string and fix the source"],"exampleFix":"// before\nconst tool = createGraphRAGTool({ vectorStore, model });\n// after\nconst tool = createGraphRAGTool({ vectorStore, indexName: 'my-index', model });","handlingStrategy":"validation","validationCode":"const indexName = requestContext?.get('indexName') ?? options.indexName;\nif (!indexName) throw new Error('createGraphRAGTool: indexName must be provided');","typeGuard":"const hasIndexName = (o: unknown): o is { indexName: string } => typeof o === 'object' && o !== null && typeof (o as any).indexName === 'string' && (o as any).indexName.length > 0;","tryCatchPattern":"try { return await tool.execute({ context, mastra, requestContext }); } catch (e) { if (e.message.startsWith('indexName is required')) { /* supply indexName and retry */ } else throw e; }","preventionTips":["Always pass indexName in tool options; use requestContext only for overrides","Add a startup config check that each RAG tool has a non-empty indexName","Keep index names in one shared constants module to avoid typos"],"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"}