{"record":{"id":"af3b3e2e401d18ad","repo":"mastra-ai/mastra","slug":"vector-name-is-required","errorCode":null,"errorMessage":"Vector name is required","messagePattern":"Vector name is required","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/vector.ts","lineNumber":51,"sourceCode":"}\n\ninterface CreateIndexRequest {\n  indexName: string;\n  dimension: number;\n  metric?: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\ninterface QueryRequest {\n  indexName: string;\n  queryVector: number[];\n  topK?: number;\n  filter?: Record<string, any>;\n  includeVector?: boolean;\n}\n\nfunction getVector(mastra: Context['mastra'], vectorName?: string): MastraVector {\n  if (!vectorName) {\n    throw new HTTPException(400, { message: 'Vector name is required' });\n  }\n\n  const vector = mastra.getVector(vectorName);\n  if (!vector) {\n    throw new HTTPException(404, { message: `Vector store ${vectorName} not found` });\n  }\n\n  return vector;\n}\n\n// Upsert vectors\nexport async function upsertVectors({\n  mastra,\n  vectorName,\n  indexName,\n  vectors,\n  metadata,\n  ids,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/vector.ts#L33-L69","documentation":"HTTP 400 thrown by getVector in the vector handler: the vectorName path/query parameter is missing, so the server cannot even look up a vector store. No MastraVector lookup is attempted.","triggerScenarios":"GET/POST to vector routes (query, upsert, etc.) without the vectorName parameter — e.g. GET /api/vectors or a client call with an undefined name.","commonSituations":"Client code building URLs with template literals where the variable is undefined/empty; renaming a vector config and leaving old client calls without a name; missing route params after API path changes.","solutions":["Pass a vectorName matching a vector registered in your Mastra instance (e.g. GET /api/vectors/my-vector/query).","Check the client call site for an undefined/empty name variable before building the URL.","Update client SDK calls to the current route signature."],"exampleFix":"// before\nawait fetch(`/api/vectors/${undefined}/query`)\n// after\nconst vectorName = 'my-store';\nawait fetch(`/api/vectors/${encodeURIComponent(vectorName)}/query`)","handlingStrategy":"validation","validationCode":"if (!vectorName) throw new Error('vectorName is required before calling vector API');\nconst res = await fetch(`/api/vectors/${encodeURIComponent(vectorName)}/query`, {...});","typeGuard":"function hasVectorName(name: string | undefined | null): name is string {\n  return typeof name === 'string' && name.length > 0;\n}","tryCatchPattern":"try {\n  return await queryVector(vectorName, params);\n} catch (e) {\n  if (isHttpException(e, 400) && /Vector name is required/.test(e.message)) {\n    throw new ConfigError('vectorName missing — check client call site');\n  }\n  throw e;\n}","preventionTips":["Validate route params client-side before building vector API URLs.","Avoid optional-chaining into URL template literals where undefined silently disappears.","Encode vector names in URLs with encodeURIComponent."],"tags":["http-400","missing-parameter","vector","api"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}