{"record":{"id":"8dd7c72997e7e07d","repo":"mastra-ai/mastra","slug":"mastra-memory-get-embedding-dimension-failed","errorCode":"MASTRA_MEMORY_GET_EMBEDDING_DIMENSION_FAILED","errorMessage":"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.","messagePattern":"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\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/memory/memory.ts","lineNumber":312,"sourceCode":"   * Probe the embedder to determine its actual output dimension.\n   * The result is cached so subsequent calls are free.\n   */\n  protected async getEmbeddingDimension(): Promise<number | undefined> {\n    if (!this.embedder) return undefined;\n    if (!this._embeddingDimensionPromise) {\n      this._embeddingDimensionPromise = (async () => {\n        try {\n          const result = await this.embedder!.doEmbed({\n            values: ['a'],\n            ...(this.embedderOptions || {}),\n          } as any);\n          const dimension = result.embeddings[0]?.length;\n          if (!dimension) {\n            throw new Error('Embedder returned no usable embedding for the dimension probe.');\n          }\n          return dimension;\n        } catch (e) {\n          throw new MastraError(\n            {\n              id: 'MASTRA_MEMORY_GET_EMBEDDING_DIMENSION_FAILED',\n              domain: ErrorDomain.MASTRA_VECTOR,\n              category: 'THIRD_PARTY',\n              text:\n                `Failed to determine the embedder's output dimension. Semantic recall cannot safely select a ` +\n                `vector index until the embedder returns a usable embedding. Check that the embedder is reachable ` +\n                `and correctly configured.`,\n            },\n            e,\n          );\n        }\n      })();\n    }\n    return this._embeddingDimensionPromise;\n  }\n\n  /**","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/memory/memory.ts#L294-L330","documentation":"This MastraError wraps any failure in getEmbeddingDimension, including the empty-probe error (1422) and network/auth errors from the embedder. It signals that the embedder's output dimension could not be determined, so semantic recall cannot safely pick or create a correctly-sized vector index. Domain is MASTRA_VECTOR, category THIRD_PARTY.","triggerScenarios":"Any call path to getEmbeddingDimension (via embeddingDimension / createEmbeddingIndex) where doEmbed throws (network failure, bad API key, model unavailable) or returns no usable embedding.","commonSituations":"Embedder provider unreachable (offline dev, DNS/proxy issues); invalid or expired API keys; wrong model name in embedder options; test stubs returning empty embeddings; rate limits on the embedding API.","solutions":["Verify the embedder is reachable: check network, API keys, and model identifiers in embedderOptions.","Call the embedder's doEmbed directly with values: ['a'] to reproduce and inspect the underlying error.","Ensure doEmbed returns { embeddings: [[...]] } with a non-empty vector.","Catch and inspect e.cause / the wrapped original error for the root cause."],"exampleFix":"// before\nconst dim = await memory.embeddingDimension(); // throws MASTRA_MEMORY_GET_EMBEDDING_DIMENSION_FAILED\n\n// after\ntry {\n  const dim = await memory.embeddingDimension();\n} catch (e) {\n  console.error('Embedder probe failed:', (e as any).cause ?? e);\n}","handlingStrategy":"try-catch","validationCode":"try { await embedder.doEmbed({ values: ['a'] }); } catch (e) { /* fix reachability/keys before calling memory.embeddingDimension() */ }","typeGuard":null,"tryCatchPattern":"try {\n  const dim = await memory.embeddingDimension();\n} catch (e) {\n  if ((e as any).id === 'MASTRA_MEMORY_GET_EMBEDDING_DIMENSION_FAILED') {\n    console.error('Embedder probe failed (network/keys/model):', (e as any).cause ?? e);\n  } else throw e;\n}","preventionTips":["Check embedder API keys and network reachability in CI before provisioning indexes.","Pin embedder model names in embedderOptions and verify against provider docs.","Handle rate limits/retries in the embedder wrapper itself."],"tags":["memory","embedder","third-party","dimension-probe","network"],"backgroundTag":"embedder-probe-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}