mastra-ai/mastra · error · Error
Embedder returned no usable embedding for the dimension prob
Error message
Embedder returned no usable embedding for the dimension probe.
What it means
Memory probes the embedder's output dimension by embedding the single string 'a' via doEmbed and reading embeddings[0].length. This plain Error is thrown when the probe result is empty, undefined, or zero-length, meaning no usable vector came back. It is then caught and wrapped as MASTRA_MEMORY_GET_EMBEDDING_DIMENSION_FAILED (error 1423).
Source
Thrown at packages/core/src/memory/memory.ts:308
*/
private _embeddingDimensionPromise?: Promise<number | undefined>;
/**
* Probe the embedder to determine its actual output dimension.
* The result is cached so subsequent calls are free.
*/
protected async getEmbeddingDimension(): Promise<number | undefined> {
if (!this.embedder) return undefined;
if (!this._embeddingDimensionPromise) {
this._embeddingDimensionPromise = (async () => {
try {
const result = await this.embedder!.doEmbed({
values: ['a'],
...(this.embedderOptions || {}),
} as any);
const dimension = result.embeddings[0]?.length;
if (!dimension) {
throw new Error('Embedder returned no usable embedding for the dimension probe.');
}
return dimension;
} catch (e) {
throw new MastraError(
{
id: 'MASTRA_MEMORY_GET_EMBEDDING_DIMENSION_FAILED',
domain: ErrorDomain.MASTRA_VECTOR,
category: 'THIRD_PARTY',
text:
`Failed to determine the embedder's output dimension. Semantic recall cannot safely select a ` +
`vector index until the embedder returns a usable embedding. Check that the embedder is reachable ` +
`and correctly configured.`,
},
e,
);
}
})();
}View on GitHub (pinned to 75dd419e61)
Solutions
- Inspect the embedder's doEmbed response shape and return embeddings: [[number, ...]] with at least one vector.
- Log the raw doEmbed result to confirm the provider returned a vector and fix the response mapping.
- Pass a supported, tested embedder implementation (FastEmbed or an AI SDK embedding model) rather than a custom stub.
Example fix
// before (stub embedder)
doEmbed: async () => ({ embeddings: [] });
// after
doEmbed: async ({ values }) => ({ embeddings: [new Array(1536).fill(0)] }); Defensive patterns
Strategy: type-guard
Validate before calling
const res = await embedder.doEmbed({ values: ['a'] });
if (!Array.isArray(res.embeddings) || !res.embeddings[0]?.length) {
throw new Error('Embedder returned empty embeddings; fix provider response mapping');
} Type guard
function hasUsableEmbedding(r) {
return !!r && Array.isArray(r.embeddings) && Array.isArray(r.embeddings[0]) && r.embeddings[0].length > 0;
} Prevention
- Validate embedder stubs in tests return embeddings: [[...]] with realistic length.
- Log raw doEmbed responses when integrating a new provider.
- Use tested embedder implementations rather than ad-hoc wrappers.
When it happens
Trigger: Calling getEmbeddingDimension/embeddingDimension when the embedder's doEmbed returns embeddings[0] undefined or an empty array — e.g. a mock/stub embedder returning { embeddings: [] }, or a provider returning an unexpected response shape.
Common situations: Fake embedders in tests that return empty embeddings; provider API changes where the response nests vectors differently; embedders configured with options that filter or limit output; broken API keys causing silently empty responses from unusual providers.
Related errors
- MASTRA_MEMORY_GET_EMBEDDING_DIMENSION_FAILED
- SEMANTIC_RECALL_MISSING_EMBEDDER
- Tried to embed message content but this Memory instance does
- MastraClient.deleteThread() requires exactly one of agentId
- No response body
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/9e14ed4ddb99e719.
Report an issue: GitHub.