{"record":{"id":"778af05617877a81","repo":"mastra-ai/mastra","slug":"vector-configuration-is-required-to-embed-text","errorCode":null,"errorMessage":"Vector configuration is required to embed text.","messagePattern":"Vector configuration is required to embed text\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/workspace/search/search-engine.ts","lineNumber":681,"sourceCode":"      return 'hybrid';\n    }\n    if (this.canVector) {\n      return 'vector';\n    }\n    if (this.canBM25) {\n      return 'bm25';\n    }\n\n    throw new Error('No search configuration available. Provide bm25 or vector config.');\n  }\n\n  /**\n   * Embed a single text, dispatching to the batch path with a one-element array\n   * when the configured embedder is batch-capable.\n   */\n  async #embedOne(text: string): Promise<number[]> {\n    if (!this.#vectorConfig) {\n      throw new Error('Vector configuration is required to embed text.');\n    }\n    const { embedder } = this.#vectorConfig;\n    if (isBatchEmbedder(embedder)) {\n      const [embedding] = await embedder([text]);\n      if (!embedding) {\n        throw new Error('Batch embedder returned no embedding for input text.');\n      }\n      return embedding;\n    }\n    return embedder(text);\n  }\n\n  /**\n   * Embed many texts. Uses a single batched call (chunked by `maxBatchSize`)\n   * when the embedder is batch-capable; otherwise falls back to parallel\n   * single-text calls.\n   */\n  async #embedAll(texts: string[]): Promise<number[][]> {","sourceCodeStart":663,"sourceCodeEnd":699,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workspace/search/search-engine.ts#L663-L699","documentation":"An embedding was requested (directly or as part of vector indexing/querying) but the engine has no `vectorConfig`, so there is no embedder to convert text into vectors. The private `#embedOne` guard throws before touching any embedder. It surfaces from `embedding`/`queryEmbedding` paths.","triggerScenarios":"Calling embedding-dependent operations such as `queryEmbedding(text)` or indexing with vector output on a SearchEngine constructed without `vectorConfig` (no vectorStore/embedder/indexName).","commonSituations":"BM25-only deployments whose indexing path unconditionally triggers vector embedding; env-based wiring where the embedding provider config failed to load; calling low-level vector APIs (embed/queryEmbedding) instead of search on a keyword-only engine.","solutions":["Supply a `vectorConfig` with a working embedder, vector store, and indexName when constructing the SearchEngine.","Skip embedding operations when `engine.canVector` is false (use BM25 search instead).","Check that the vector/embedding provider configuration (API keys, model) is present in the environment before engine construction."],"exampleFix":"// before\nconst engine = new SearchEngine({ bm25: {} });\nawait engine.queryEmbedding('query'); // throws\n\n// after\nconst engine = new SearchEngine({\n  bm25: {},\n  vectorConfig: { vectorStore, embedder, indexName: 'docs' },\n});\nawait engine.queryEmbedding('query');","handlingStrategy":"validation","validationCode":"if (!engine.canVector) {\n  throw new Error('Embedding requires vector configuration (embedder + vector store).');\n}\nconst vec = await engine.queryEmbedding(text);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard embedding/vector operations behind `engine.canVector`.","Wire the embedder and vector store from a single validated config module at startup.","Use BM25-only flows when no embedding provider is configured."],"tags":["embeddings","vector-search","configuration","misconfiguration"],"backgroundTag":"missing-vector-config","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}