Mintplex-Labs/anything-llm · error · Error

No file location in metadata

Error message

No file location in metadata

What it means

Thrown by WorkspaceParsedFiles.moveToDocumentsAndEmbed when the parsed file's metadata (JSON) either fails to parse or contains no 'location' field. safeJsonParse defaults to {}, and a missing location key is treated as a failure because the embedding step needs the original file path.

Source

Thrown at server/models/workspaceParsedFiles.js:122

   * Moves a parsed file to the documents and embeds it.
   * @param {import("@prisma/client").users | null} user - The user performing the operation.
   * @param {number} fileId - The ID of the parsed file.
   * @param {import("@prisma/client").workspaces} workspace - The workspace the file belongs to.
   * @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 = [],

View on GitHub (pinned to 526360e320)

Solutions

  1. Re-run the original file upload/parse so the row is recreated with complete metadata including location.
  2. Delete the orphaned parsed-file row and re-upload the source file.
  3. If repairing by hand, backfill metadata.location to point at the file under the direct uploads path.
Defensive patterns

Strategy: validation

Validate before calling

const meta = safeJsonParse(parsedFile.metadata, {});
if (!meta || !meta.location) {
  return respond(409, 'Parsed file missing location metadata; re-upload the source');
}

Type guard

const hasLocation = (m) => m != null && typeof m === 'object' && typeof m.location === 'string' && m.location.length > 0;

Try / catch

const { success, error } = await WorkspaceParsedFiles.moveToDocumentsAndEmbed(user, fileId, workspace);
if (!success && /No file location/.test(error)) {
  // delete the orphaned row and prompt re-upload
}

Prevention

When it happens

Trigger: Calling embed on a workspace_parsed_files row whose metadata column is null, malformed JSON, or a valid JSON object lacking a 'location' property.

Common situations: The upload/parse pipeline that created the row crashed or was interrupted before writing metadata.location. A schema/version change dropped the location field. Manual DB edits corrupted the metadata JSON.

Related errors


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