{"record":{"id":"9109b129266d119f","repo":"mastra-ai/mastra","slug":"no-embeddings-generated","errorCode":null,"errorMessage":"No embeddings generated","messagePattern":"No embeddings generated","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/fastembed/src/index.ts","lineNumber":44,"sourceCode":"export async function warmup() {\n  await warmupFastEmbedModels();\n}\n\n// Shared function to generate embeddings using fastembed\nasync function generateEmbeddings(values: string[], modelType: FastEmbedModelType) {\n  const model = await getCachedModel(modelType);\n\n  // model.embed() returns an AsyncGenerator that processes texts in batches (default size 256)\n  const embeddings = model.embed(values);\n\n  const allResults = [];\n  for await (const result of embeddings) {\n    // result is an array of embeddings, one for each text in the batch\n    // We convert each Float32Array embedding to a regular number array\n    allResults.push(...result.map(embedding => Array.from(embedding)));\n  }\n\n  if (allResults.length === 0) throw new Error('No embeddings generated');\n\n  return {\n    embeddings: allResults,\n  };\n}\n\n// E5 models are asymmetric: queries and passages must be embedded with different prefixes.\nasync function generatePrefixedEmbeddings(\n  values: string[],\n  modelType: FastEmbedModelType,\n  prefix: 'query' | 'passage',\n) {\n  return generateEmbeddings(\n    values.map(value => `${prefix}: ${value}`),\n    modelType,\n  );\n}\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/fastembed/src/index.ts#L26-L62","documentation":"generateEmbeddings() consumes the async iterable of batch embeddings from the fastembed model; if no results arrive at all (allResults.length === 0), it throws 'No embeddings generated'. This indicates the underlying model produced zero batches for the given input.","triggerScenarios":"Calling embed/generatePrefixedEmbeddings (via doEmbed) with an empty input array, or with a model/embedder that silently yields nothing for the batch.","commonSituations":"Empty texts array passed to an AI provider's embed call; upstream filtering removed all inputs; integration where a zero-length batch slips through validation at a higher layer.","solutions":["Check the input: ensure the texts/embeddings request contains at least one non-empty item before calling embed.","Add a guard in your calling code to skip or error early on empty input arrays.","If input is non-empty, verify the fastembed model initialized correctly (model files loaded) — a misloaded model can yield no batches."],"exampleFix":"// before\nawait model.embed([]);\n// after\nconst texts = getInputTexts();\nif (texts.length === 0) return { embeddings: [] };\nconst { embeddings } = await model.embed(texts);","handlingStrategy":"validation","validationCode":"function assertNonEmptyInputs(texts) {\n  if (!Array.isArray(texts) || texts.length === 0) {\n    throw new Error('embed() requires at least one input text');\n  }\n}","typeGuard":"function hasItems(x) {\n  return Array.isArray(x) && x.length > 0;\n}","tryCatchPattern":"try {\n  const { embeddings } = await model.embed(texts);\n  return embeddings;\n} catch (e) {\n  if (e.message === 'No embeddings generated') {\n    return { embeddings: [] }; // or skip this batch\n  }\n  throw e;\n}","preventionTips":["Guard empty input arrays before calling embed; short-circuit with an empty result.","Filter inputs upstream and track counts so an all-filtered batch is detected early.","Add a unit test for the empty-batch path in your embedding pipeline."],"tags":["embeddings","empty-input","validation","fastembed"],"backgroundTag":"empty-input-no-results","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}