Mintplex-Labs/anything-llm · error · Error
File not found
Error message
File not found
What it means
Thrown by WorkspaceParsedFiles.moveToDocumentsAndEmbed when this.get({id, userId?, workspaceId}) returns null — i.e. no workspace_parsed_files row matches the given fileId (optionally scoped to the acting user) and the workspace. Reached via POST /workspace/:slug/embed-parsed-file/:fileId.
Source
Thrown at server/models/workspaceParsedFiles.js:117
});
return _sum.tokenCountEstimate || 0;
},
/**
* 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);View on GitHub (pinned to 526360e320)
Solutions
- Confirm the fileId still exists in workspace_parsed_files for this workspace before calling.
- Avoid retrying after a success — the row is removed in finally.
- If acting as a non-admin, ensure the file belongs to that user (userId scope).
Defensive patterns
Strategy: validation
Validate before calling
const parsedFile = await WorkspaceParsedFiles.get({ id: fileId, workspaceId: workspace.id });
if (!parsedFile) return respond(404, 'Parsed file not found'); Try / catch
const { success, error } = await WorkspaceParsedFiles.moveToDocumentsAndEmbed(user, fileId, workspace);
if (!success && /File not found/.test(error)) {
// tell the client to refresh its parsed-file list
} Prevention
- Do not retry embed after a success — the parsed-file row is deleted in finally.
- Scope fileId lookups by workspace (and user) to avoid cross-tenant mismatches.
When it happens
Trigger: POST /workspace/:slug/embed-parsed-file/:fileId where the fileId does not exist, belongs to a different workspace, or (when a user is passed) belongs to a different user. Also if the file was already processed (the finally block deletes the row on every run).
Common situations: The parsed file was already embedded and its row deleted by a previous attempt. User retries after the first success. Cross-workspace fileId copy/paste. Stale UI listing a fileId that no longer exists.
Related errors
- Failed to embed document
- No file location in metadata
- Source file not found
- Workspace not found
- Bad Request
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/c8a7bca34a23923e.
Report an issue: GitHub.