Mintplex-Labs/anything-llm · error · Error
Failed to embed document
Error message
Failed to embed document
What it means
Thrown by WorkspaceParsedFiles.moveToDocumentsAndEmbed when Document.addDocuments reports at least one failedToEmbed entry — it surfaces errors[0] if present, otherwise this default message. addDocuments runs the full ingestion pipeline (text processing + vectorization), so a failure anywhere downstream (collector unreachable, embedder/vector-DB misconfigured, unsupported file type) bubbles up here.
Source
Thrown at server/models/workspaceParsedFiles.js:149
fs.mkdirSync(customDocsPath, { recursive: true });
// Copy the file to custom-documents
const targetPath = path.join(customDocsPath, path.basename(location));
fs.copyFileSync(sourceFile, targetPath);
fs.unlinkSync(sourceFile);
const {
failedToEmbed = [],
errors = [],
embedded = [],
} = await Document.addDocuments(
workspace,
[`custom-documents/${path.basename(location)}`],
parsedFile.userId
);
if (failedToEmbed.length > 0)
throw new Error(errors[0] || "Failed to embed document");
const document = await Document.get({
workspaceId: workspace.id,
docpath: embedded[0],
});
return { success: true, error: null, document };
} catch (error) {
console.error("Failed to move and embed file:", error);
return { success: false, error: error.message, document: null };
} finally {
await this.delete({
id: parseInt(fileId),
...(user ? { userId: user.id } : {}),
workspaceId: workspace.id,
});
}
},
View on GitHub (pinned to 526360e320)
Solutions
- Check server and collector logs for the specific addDocuments error, which is the real root cause.
- Verify the embedding provider credentials and vector database connection in settings.
- Ensure the collector service is running and reachable from the server.
- Retry once the underlying provider/DB issue is resolved.
Defensive patterns
Strategy: try-catch
Try / catch
const { success, error } = await WorkspaceParsedFiles.moveToDocumentsAndEmbed(user, fileId, workspace);
if (!success && /embed document/i.test(error)) {
// inspect server + collector logs for the real addDocuments cause, fix provider/vector DB, then retry
} Prevention
- Verify embedding-provider credentials and vector-database connectivity before bulk embedding.
- Keep the collector service running and reachable.
- Watch embedding API quota/rate limits during large imports.
When it happens
Trigger: POST /workspace/:slug/embed-parsed-file/:fileId where the file copies to custom-documents successfully but embedding fails: the collector service is down, the configured embedding provider rejects the input, the vector database is unreachable, or the document type is unsupported.
Common situations: Embeddings provider API key missing/invalid. Vector database (e.g. LanceDB/Chroma/Pinecone) not initialized or wrong URL. Collector process not running. Rate limit or quota hit on the embedding API. Unsupported/corrupt file content that cannot be parsed.
Related errors
- File not found
- No file location in metadata
- Source file not found
- res.statusText || "Error setting watch status for document."
- Error setting suggested messages.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/2bee37be48800cc5.
Report an issue: GitHub.