{"record":{"id":"2bee37be48800cc5","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-embed-document","errorCode":null,"errorMessage":"Failed to embed document","messagePattern":"Failed to embed document","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/models/workspaceParsedFiles.js","lineNumber":149,"sourceCode":"        fs.mkdirSync(customDocsPath, { recursive: true });\n\n      // Copy the file to custom-documents\n      const targetPath = path.join(customDocsPath, path.basename(location));\n      fs.copyFileSync(sourceFile, targetPath);\n      fs.unlinkSync(sourceFile);\n\n      const {\n        failedToEmbed = [],\n        errors = [],\n        embedded = [],\n      } = await Document.addDocuments(\n        workspace,\n        [`custom-documents/${path.basename(location)}`],\n        parsedFile.userId\n      );\n\n      if (failedToEmbed.length > 0)\n        throw new Error(errors[0] || \"Failed to embed document\");\n\n      const document = await Document.get({\n        workspaceId: workspace.id,\n        docpath: embedded[0],\n      });\n      return { success: true, error: null, document };\n    } catch (error) {\n      console.error(\"Failed to move and embed file:\", error);\n      return { success: false, error: error.message, document: null };\n    } finally {\n      await this.delete({\n        id: parseInt(fileId),\n        ...(user ? { userId: user.id } : {}),\n        workspaceId: workspace.id,\n      });\n    }\n  },\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/models/workspaceParsedFiles.js#L131-L167","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"const { success, error } = await WorkspaceParsedFiles.moveToDocumentsAndEmbed(user, fileId, workspace);\nif (!success && /embed document/i.test(error)) {\n  // inspect server + collector logs for the real addDocuments cause, fix provider/vector DB, then retry\n}","preventionTips":["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."],"tags":["workspace","parsed-files","embedding","vector-database","provider"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}