Mintplex-Labs/anything-llm · error · Error

Source file not found

Error message

Source file not found

What it means

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.

Source

Thrown at server/models/workspaceParsedFiles.js:126

   * @returns {Promise<{ success: boolean, error: string | null, document: import("@prisma/client").workspace_documents | null }>} The result of the operation.
   */
  moveToDocumentsAndEmbed: async function (user = null, fileId, workspace) {
    try {
      const parsedFile = await this.get({
        id: parseInt(fileId),
        ...(user ? { userId: user.id } : {}),
        workspaceId: workspace.id,
      });
      if (!parsedFile) throw new Error("File not found");

      // Get file location from metadata
      const metadata = safeJsonParse(parsedFile.metadata, {});
      const location = metadata.location;
      if (!location) throw new Error("No file location in metadata");

      // Get file from metadata location
      const sourceFile = path.join(directUploadsPath, path.basename(location));
      if (!fs.existsSync(sourceFile)) throw new Error("Source file not found");

      // Move to custom-documents
      const customDocsPath = path.join(documentsPath, "custom-documents");
      if (!fs.existsSync(customDocsPath))
        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)}`],

View on GitHub (pinned to 526360e320)

Solutions

  1. Restore the original uploaded file into the direct-uploads directory, then retry.
  2. Ensure the direct-uploads storage volume is persistent across restarts.
  3. Verify the directUploadsPath config matches the directory the collector writes uploads to.
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
const source = path.join(directUploadsPath, path.basename(location));
if (!fs.existsSync(source)) return respond(410, 'Source file missing; re-upload');

Try / catch

const { success, error } = await WorkspaceParsedFiles.moveToDocumentsAndEmbed(user, fileId, workspace);
if (!success && /Source file not found/.test(error)) {
  // restore the upload, then retry
}

Prevention

When it happens

Trigger: 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).

Common situations: 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).

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/9a78724fff2dd0c8. Report an issue: GitHub.