{"record":{"id":"1bb74cd7b8523e6f","repo":"mastra-ai/mastra","slug":"no-search-configuration-available-provide-bm25-or","errorCode":null,"errorMessage":"No search configuration available. Provide bm25 or vector config.","messagePattern":"No search configuration available\\. Provide bm25 or vector config\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/workspace/search/search-engine.ts","lineNumber":672,"sourceCode":"      }\n      if (requestedMode === 'hybrid' && !this.canHybrid) {\n        throw new Error('Hybrid search requires both vector and BM25 configuration.');\n      }\n      return requestedMode;\n    }\n\n    // Auto-determine based on available configuration\n    if (this.canHybrid) {\n      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    }","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workspace/search/search-engine.ts#L654-L690","documentation":"The engine was asked to search with no mode specified, so it tried to auto-select one, but neither vector nor BM25 was configured at all. With no index and no embedding pipeline there is nothing to search against, so it throws rather than returning empty results.","triggerScenarios":"Calling `search(query)` (or `search(query, {})`) on a SearchEngine constructed with neither `vectorConfig` nor a BM25 config — `canVector`, `canBM25`, and `canHybrid` are all false.","commonSituations":"Instantiating SearchEngine with an empty/omitted options object in a Workspace setup; config loading that silently drops the search options (bad env vars, missing embedder key); code that defers configuring search but already calls search during startup or tests.","solutions":["Construct the SearchEngine with at least one backend: a `bm25` config for keyword search or a `vectorConfig` (vectorStore + embedder + indexName) for semantic search.","If search should be optional, check `engine.canBM25 || engine.canVector` before calling search and skip/handle the no-search case.","Verify your config/env loading actually reaches the SearchEngine constructor (log the options before constructing)."],"exampleFix":"// before\nconst engine = new SearchEngine();\nawait engine.search('query'); // throws\n\n// after\nconst engine = new SearchEngine({\n  bm25: {},\n  vectorConfig: { vectorStore, embedder, indexName: 'docs' },\n});\nawait engine.search('query');","handlingStrategy":"validation","validationCode":"if (!engine.canBM25 && !engine.canVector) {\n  throw new Error('SearchEngine has no search backend configured; provide bm25 or vectorConfig.');\n}\nreturn engine.search(query);","typeGuard":null,"tryCatchPattern":"try {\n  results = await engine.search(query);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('No search configuration available')) {\n    results = []; // or configure a backend and retry\n  } else {\n    throw e;\n  }\n}","preventionTips":["Always construct SearchEngine with at least one backend (bm25 or vectorConfig).","Assert search config presence in app startup/health checks.","Log the resolved options before constructing the engine to catch silently dropped config."],"tags":["search","configuration","misconfiguration","setup"],"backgroundTag":"search-mode-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}