Bug Report
Description
The legacy listVectorStores function in packages/server/src/server/handlers/vector.ts (lines 190-207) maps vector entries using id: vector.id without any fallback, which can produce undefined values when a MastraVector instance does not have an id property set.
This directly violates the listVectorsResponseSchema which declares id as a required z.string() field (non-optional):
// packages/server/src/server/schemas/vectors.ts
export const listVectorsResponseSchema = z.object({
vectors: z.array(z.object({
id: z.string(), // <-- required, not optional
name: z.string(),
type: z.string(),
...
}))
});
Root Cause
The newer LIST_VECTORS_ROUTE (lines 383-410) correctly uses:
id: vector.id || name, // fallback to the registration key if id is not set
But the older standalone listVectorStores function uses:
id: vector.id, // no fallback — can be undefined!
Impact
- When a vector store is registered without an explicit
id property, listVectorStores returns { id: undefined, name, type }
- This fails Zod schema validation (schema expects a string, gets undefined)
- Any client calling the legacy route gets malformed data or a runtime error
Fix
Apply the same id: vector.id || name fallback pattern used in LIST_VECTORS_ROUTE to the legacy listVectorStores function:
const vectorList = Object.entries(vectors).map(([name, vector]) => ({
name,
id: vector.id || name, // fallback to registration key
type: vector.constructor.name,
}));
File
packages/server/src/server/handlers/vector.ts — listVectorStores function (~line 198)
Bug Report
Description
The legacy
listVectorStoresfunction inpackages/server/src/server/handlers/vector.ts(lines 190-207) maps vector entries usingid: vector.idwithout any fallback, which can produceundefinedvalues when aMastraVectorinstance does not have anidproperty set.This directly violates the
listVectorsResponseSchemawhich declaresidas a requiredz.string()field (non-optional):Root Cause
The newer
LIST_VECTORS_ROUTE(lines 383-410) correctly uses:But the older standalone
listVectorStoresfunction uses:Impact
idproperty,listVectorStoresreturns{ id: undefined, name, type }Fix
Apply the same
id: vector.id || namefallback pattern used inLIST_VECTORS_ROUTEto the legacylistVectorStoresfunction:File
packages/server/src/server/handlers/vector.ts—listVectorStoresfunction (~line 198)