{"record":{"id":"08cca6b52f46c9c5","repo":"mastra-ai/mastra","slug":"embedder-returned-no-vector-for-entry-documentid","errorCode":null,"errorMessage":"Embedder returned no vector for ${entry.documentId}","messagePattern":"Embedder returned no vector for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/semantic-index.ts","lineNumber":172,"sourceCode":"  }\n\n  async #apply(entry: KnowledgeSemanticOutboxEntry): Promise<void> {\n    if (entry.operation === 'delete') {\n      await this.#deleteDocument(entry.documentId);\n      return;\n    }\n\n    const document = await this.#loadDocument(entry);\n    if (!document) {\n      await this.#deleteDocument(entry.documentId);\n      return;\n    }\n    const result = await this.#embedder.doEmbed({\n      values: [document.text],\n      ...(this.#embedderOptions ?? {}),\n    } as never);\n    const embedding = result.embeddings[0];\n    if (!embedding?.length) throw new Error(`Embedder returned no vector for ${entry.documentId}`);\n    const indexName = this.#indexName(embedding.length);\n    const indexes = await this.#knowledgeIndexes();\n    if (!indexes.includes(indexName)) {\n      await this.#vector.createIndex({ indexName, dimension: embedding.length });\n    }\n    for (const existingIndex of indexes) {\n      if (existingIndex !== indexName) {\n        await this.#vector.deleteVectors({ indexName: existingIndex, ids: [entry.documentId] });\n      }\n    }\n    await this.#vector.upsert({\n      indexName,\n      ids: [entry.documentId],\n      vectors: [embedding],\n      metadata: [this.#metadata(document)],\n    });\n  }\n","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/semantic-index.ts#L154-L190","documentation":"`#apply` in packages/memory/src/processors/observational-memory/subconscious/semantic-index.ts:172 embeds a knowledge document's text to upsert it into the vector index. It throws a plain Error when the embedder resolves with no vector for that document, identifying the culprit as `entry.documentId`. The document cannot be indexed at all without its vector.","triggerScenarios":"During outbox drain, `doEmbed({ values: [document.text] })` returns `{ embeddings: [] }` or an empty first vector — provider content filter rejecting the text, empty/whitespace document text, a broken custom embedder, or an adapter silently resolving empty on quota exhaustion.","commonSituations":"Documents containing content the embedding provider refuses (safety filters); empty text after preprocessing/truncation bugs; custom embedder wrappers with the wrong return shape; provider outage that resolves instead of rejecting.","solutions":["Fix or replace the embedder so it returns a non-empty vector per value; check provider logs/quota.","Validate document text before capture (non-empty, within size limits, no content that trips provider filters).","Inspect the failing documentId's text in the store and embed it manually to reproduce.","The failed entry is released back to the outbox, so retry after fixing the embedder."],"exampleFix":"// before (empty text reaches the embedder)\nawait capture({ id: 'doc1', text: truncatedToEmpty(doc.text) });\n// after\nconst text = doc.text?.trim();\nif (!text) return; // skip empty documents instead of failing the drain\nawait capture({ id: 'doc1', text });","handlingStrategy":"validation","validationCode":"const text = document.text?.trim();\nif (!text) throw new Error(`Refusing to index empty document ${document.id}`);\nif (text.length > MAX_EMBED_CHARS) throw new Error(`Document ${document.id} exceeds embedder limit`);","typeGuard":"function isEmbeddableDocument(doc) {\n  return typeof doc?.text === 'string' && doc.text.trim().length > 0;\n}","tryCatchPattern":"try {\n  await indexingPipeline.flush();\n} catch (e) {\n  if (e.message.startsWith('Embedder returned no vector for')) {\n    const docId = e.message.split('for ')[1];\n    logger.error(`embedder returned no vector for ${docId}; quarantining document`);\n    await quarantineDocument(docId); // keep the drain moving\n    return indexingPipeline.flush();\n  }\n  throw e;\n}","preventionTips":["Validate document text (non-empty, size limits) before capture.","Pre-test documents against provider content filters for your embedding model.","Smoke-test the embedder at startup and monitor empty-embedding responses."],"tags":["embeddings","indexing","outbox"],"backgroundTag":"empty-embedding-response","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}