mastra-ai/mastra · error
vectorStoreName is required, got: ${vectorStoreName}
Error message
vectorStoreName is required, got: ${vectorStoreName} What it means
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.
Source
Thrown at packages/rag/src/tools/graph-rag.ts:53
const inputSchema = options.enableFilter ? filterSchema : z.object(baseSchema).passthrough();
return createTool({
id: toolId,
inputSchema,
outputSchema,
description: toolDescription,
execute: async (inputData, context) => {
// See vector-query.ts for the same pattern: `context` from `createTool`
// is loosely typed; cast is safe because `createObservabilityContext`
// falls back to `noOpTracingContext` when `tracingContext` is undefined.
const { requestContext, mastra, tracingContext } = (context as any) || {};
const observabilityContext = createObservabilityContext(tracingContext);
const parentSpan = observabilityContext.tracingContext?.currentSpan;
const indexName: string = requestContext?.get('indexName') ?? options.indexName;
const vectorStoreName: string =
'vectorStore' in options ? storeName : (requestContext?.get('vectorStoreName') ?? storeName);
if (!indexName) throw new Error(`indexName is required, got: ${indexName}`);
if (!vectorStoreName) throw new Error(`vectorStoreName is required, got: ${vectorStoreName}`);
const includeSources: boolean = requestContext?.get('includeSources') ?? options.includeSources ?? true;
const randomWalkSteps: number | undefined =
requestContext?.get('randomWalkSteps') ?? graphOptions.randomWalkSteps;
const restartProb: number | undefined = requestContext?.get('restartProb') ?? graphOptions.restartProb;
const topK: number = requestContext?.get('topK') ?? (inputData.topK as number) ?? 10;
const filter: unknown = requestContext?.get('filter') ?? inputData.filter;
const queryText = inputData.queryText;
const providerOptions: ProviderOptions['providerOptions'] =
requestContext?.get('providerOptions') ?? options.providerOptions;
const enableFilter = !!requestContext?.get('filter') || (options.enableFilter ?? false);
const logger = mastra?.getLogger();
if (logger) {
logger.debug('[GraphRAGTool] execute called with:', { queryText, topK, filter });
}
try {
const topKValue = coerceTopK(topK);View on GitHub (pinned to 75dd419e61)
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
Example fix
// before
const tool = createGraphRAGTool({ indexName: 'docs', model });
// after
const tool = createGraphRAGTool({ vectorStore, indexName: 'docs', model }); Defensive patterns
Strategy: validation
Validate before calling
const vectorStoreName = 'vectorStore' in options ? storeName : (requestContext?.get('vectorStoreName') ?? storeName);
if (!vectorStoreName) throw new Error('createGraphRAGTool: vectorStoreName must be provided'); Type guard
const isNamedVector = (v: unknown): v is { name: string } => typeof v === 'object' && v !== null && typeof (v as any).name === 'string'; Try / catch
try { return await tool.execute(ctx); } catch (e) { if (e.message.startsWith('vectorStoreName is required')) { /* pass vectorStore or set vectorStoreName */ } else throw e; } Prevention
- 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
When it happens
Trigger: Calling the tool when no vectorStore option is passed AND neither requestContext.get('vectorStoreName') nor the derived storeName is set; passing an empty string.
Common situations: 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.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- indexName is required, got: ${indexName}
- indexName is required, got: ${indexName}
- VectorStoreResolver returned invalid value: expected MastraV
- Google RBAC roleMapping is required.
- Cookie password must be at least 32 characters. Set OKTA_COO
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/39242cf245fb3902.
Report an issue: GitHub.