{"record":{"id":"057091042a7fc87f","repo":"mastra-ai/mastra","slug":"index-name-is-required","errorCode":null,"errorMessage":"Index name is required","messagePattern":"Index name is required","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/vector.ts","lineNumber":154,"sourceCode":"  try {\n    const vector = getVector(mastra, vectorName);\n\n    const indexes = await vector.listIndexes();\n    return indexes.filter(Boolean);\n  } catch (error) {\n    return handleError(error, 'Error listing indexes');\n  }\n}\n\n// Describe index\nexport async function describeIndex({\n  mastra,\n  vectorName,\n  indexName,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { indexName?: string }) {\n  try {\n    if (!indexName) {\n      throw new HTTPException(400, { message: 'Index name is required' });\n    }\n\n    const vector = getVector(mastra, vectorName);\n    const stats: IndexStats = await vector.describeIndex({ indexName });\n\n    return {\n      dimension: stats.dimension,\n      count: stats.count,\n      metric: stats.metric?.toLowerCase(),\n    };\n  } catch (error) {\n    return handleError(error, 'Error describing index');\n  }\n}\n\n// Delete index\nexport async function deleteIndex({\n  mastra,","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/vector.ts#L136-L172","documentation":"This HTTP 400 error is thrown by the describeIndex handler when indexName is missing or falsy (undefined, null, or empty string). describeIndex requires an explicit index to return its stats (dimension, count, metric), so the handler short-circuits with a clear message rather than attempting a store call. There is no 'describe all indexes' fallback on this route.","triggerScenarios":"Calling the describe-index route with indexName omitted from the body/query; passing an empty string after a failed lookup or unset variable; passing null from a caller that expected stats for the whole store.","commonSituations":"UI code building the request before the user selects an index; refactors that renamed indexName to name and left the old field undefined; dynamic index names interpolated from config that resolve to ''.","solutions":["Always pass a non-empty indexName string to the describe-index request.","Log/inspect the value of indexName before the call to catch empty-string cases.","If you need store-level info, use the store stats route/handler instead of describeIndex.","Check for renamed fields after SDK/API upgrades."],"exampleFix":"// before\nconst stats = await describeIndex({ mastra, vectorName: 'pg', indexName: selectedName ?? '' });\n// after\nif (!selectedName) return null;\nconst stats = await describeIndex({ mastra, vectorName: 'pg', indexName: selectedName });","handlingStrategy":"type-guard","validationCode":"function canDescribe(indexName) { return typeof indexName === 'string' && indexName.trim().length > 0; }\nif (!canDescribe(selectedIndex)) return null;\nconst stats = await client.describeIndex({ indexName: selectedIndex });","typeGuard":"function hasIndexName(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try {\n  return await client.describeIndex({ indexName });\n} catch (e) {\n  if (e.status === 400 && /Index name is required/.test(e.message)) {\n    return null; // no index selected yet\n  }\n  throw e;\n}","preventionTips":["Check the index name is a non-empty string before calling describe.","Treat describeIndex as index-specific; use store stats for store-wide info.","Beware empty-string fallbacks like ?? '' masking a missing selection.","Verify field names after API/SDK upgrades."],"tags":["http-400","validation","vector","rest-api"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}