{"record":{"id":"9a78724fff2dd0c8","repo":"Mintplex-Labs/anything-llm","slug":"source-file-not-found","errorCode":null,"errorMessage":"Source file not found","messagePattern":"Source file not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/models/workspaceParsedFiles.js","lineNumber":126,"sourceCode":"   * @returns {Promise<{ success: boolean, error: string | null, document: import(\"@prisma/client\").workspace_documents | null }>} The result of the operation.\n   */\n  moveToDocumentsAndEmbed: async function (user = null, fileId, workspace) {\n    try {\n      const parsedFile = await this.get({\n        id: parseInt(fileId),\n        ...(user ? { userId: user.id } : {}),\n        workspaceId: workspace.id,\n      });\n      if (!parsedFile) throw new Error(\"File not found\");\n\n      // Get file location from metadata\n      const metadata = safeJsonParse(parsedFile.metadata, {});\n      const location = metadata.location;\n      if (!location) throw new Error(\"No file location in metadata\");\n\n      // Get file from metadata location\n      const sourceFile = path.join(directUploadsPath, path.basename(location));\n      if (!fs.existsSync(sourceFile)) throw new Error(\"Source file not found\");\n\n      // Move to custom-documents\n      const customDocsPath = path.join(documentsPath, \"custom-documents\");\n      if (!fs.existsSync(customDocsPath))\n        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)}`],","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/models/workspaceParsedFiles.js#L108-L144","documentation":"Thrown by WorkspaceParsedFiles.moveToDocumentsAndEmbed when the source file (path.join(directUploadsPath, path.basename(location))) does not exist on disk (fs.existsSync false). The metadata.location was present but the underlying file is gone, so the copy-to-custom-documents step cannot proceed.","triggerScenarios":"Embedding a parsed file whose original upload artifact under the direct-uploads directory was deleted, moved, or never written (e.g. storage volume changed, cleanup job ran, container restart lost an ephemeral volume).","commonSituations":"Docker/server restarted with a non-persistent uploads volume. An external cleanup or migration removed the direct-uploads directory. Storage path misconfiguration (directUploadsPath points elsewhere than where uploads land).","solutions":["Restore the original uploaded file into the direct-uploads directory, then retry.","Ensure the direct-uploads storage volume is persistent across restarts.","Verify the directUploadsPath config matches the directory the collector writes uploads to."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst source = path.join(directUploadsPath, path.basename(location));\nif (!fs.existsSync(source)) return respond(410, 'Source file missing; re-upload');","typeGuard":null,"tryCatchPattern":"const { success, error } = await WorkspaceParsedFiles.moveToDocumentsAndEmbed(user, fileId, workspace);\nif (!success && /Source file not found/.test(error)) {\n  // restore the upload, then retry\n}","preventionTips":["Mount the direct-uploads directory on persistent storage.","Keep directUploadsPath consistent with where the collector writes uploads.","Avoid manual cleanup of the uploads directory."],"tags":["workspace","parsed-files","filesystem","storage"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}