Mintplex-Labs/anything-llm · error · Error

Could not embed document chunks! This document will not be r

Error message

Could not embed document chunks! This document will not be recorded.

What it means

In LanceVectorDb.addDocumentToNamespace, when embedding produces no vectors the else branch throws before any LanceDB table is written, so the document is not recorded. Identical in intent to the AstraDB/Chroma 'Could not embed document chunks' guards: the failure is upstream in the embedding engine, not in LanceDB.

Source

Thrown at server/utils/vectorDbProviders/lance/index.js:394

          const vectorRecord = {
            id: uuidv4(),
            values: vector,
            // [DO NOT REMOVE]
            // LangChain will be unable to find your text if you embed manually and dont include the `text` key.
            // https://github.com/hwchase17/langchainjs/blob/2def486af734c0ca87285a48f1a04c057ab74bdf/langchain/src/vectorstores/pinecone.ts#L64
            metadata: { ...metadata, text: textChunks[i] },
          };

          vectors.push(vectorRecord);
          submissions.push({
            ...vectorRecord.metadata,
            id: vectorRecord.id,
            vector: vectorRecord.values,
          });
          documentVectors.push({ docId, vectorId: vectorRecord.id });
        }
      } else {
        throw new Error(
          "Could not embed document chunks! This document will not be recorded."
        );
      }

      if (vectors.length > 0) {
        const chunks = [];
        for (const chunk of toChunks(vectors, 500)) chunks.push(chunk);

        this.logger("Inserting vectorized chunks into LanceDB collection.");
        const { client } = await this.connect();
        await this.updateOrCreateCollection(client, submissions, namespace);
        await storeVectorResult(chunks, fullFilePath);
      }

      await DocumentVectors.bulkInsert(documentVectors);
      return { vectorized: true, error: null };
    } catch (e) {
      this.logger("addDocumentToNamespace", e.message);

View on GitHub (pinned to 20f6d3546c)

Solutions

  1. Validate the embedding engine first: embed a short string directly and confirm a non-empty vector array.
  2. Fix credentials/base-path env (e.g. OLLAMA_BASE_PATH, LOCAL_AI_BASE_PATH, OPEN_AI_KEY) and restart.
  3. Retry with a text-rich document to rule out empty extraction.
  4. Re-embed the failed document once the embedder is healthy.
Defensive patterns

Strategy: validation

Validate before calling

const vectors = await LLMConnector.embedChunks(textChunks);
if (!Array.isArray(vectors) || vectors.length === 0) {
  throw new Error('Embedding returned no vectors - check EMBEDDING_ENGINE and its endpoint.');
}

Try / catch

try {
  const r = await vectorDb.addDocumentToNamespace(/* ... */);
  if (!r.vectorized && /Could not embed document chunks/i.test(r.error)) {
    return { ok: false, reason: 'embedding-engine' };
  }
} catch (e) { throw e; }

Prevention

When it happens

Trigger: Embedding a workspace document when the configured embedder returns an empty vector list: unreachable LocalAI/Ollama/LM Studio embedder, exhausted API quota, empty text after document parsing.

Common situations: EMBEDDING_ENGINE=ollama with the embedding model not pulled/loaded; embedder base-path env pointing at a stopped service; scanned PDFs with no text layer; embedder API key revoked.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18). Data as JSON: /api/errors/291d289ca27c48a6. Report an issue: GitHub.