n8n-io/n8n · warning · NotFoundError
Could not find the folder: ${folderId}
Error message
Could not find the folder: ${folderId} What it means
NotFoundError (HTTP 404) whose message is the `FolderNotFoundError.message` (template 'Could not find the folder: <folderId>'), re-thrown at folder.controller.ts:73 inside `createFolder` when `folderService.createFolder(payload, projectId)` rejects with `FolderNotFoundError` — typically because the requested parent folder in the payload does not exist in the project.
Source
Thrown at packages/cli/src/controllers/folder.controller.ts:73
}
}
@Post('/')
@ProjectScope('folder:create')
@Licensed('feat:folders')
async createFolder(
req: AuthenticatedRequest<{ projectId: string }>,
_res: Response,
@Body payload: CreateFolderDto,
) {
const { projectId } = req.params;
try {
const folder = await this.folderService.createFolder(payload, projectId);
return folder;
} catch (e) {
if (e instanceof FolderNotFoundError) {
throw new NotFoundError(e.message);
}
throw new InternalServerError(undefined, e);
}
}
@Get('/:folderId/tree')
@ProjectScope('folder:read')
@Licensed('feat:folders')
async getFolderTree(
req: AuthenticatedRequest<{ projectId: string; folderId: string }>,
_res: Response,
) {
const { projectId, folderId } = req.params;
try {
const tree = await this.folderService.getFolderTree(folderId, projectId);
return tree;
} catch (e) {View on GitHub (pinned to 5ac6606e81)
Solutions
- Confirm the parent folder exists in the same project via `GET /projects/<projectId>/folders`.
- Omit `parentFolderId` (or set to null) to create at the project root.
- Refresh the folder tree before submitting and re-send with the current parent ID.
- Guard against deleted parents in the client before submit.
Example fix
// before
POST /projects/p1/folders { "parentFolderId": "stale-xyz", "name": "Sub" }
// 404 Could not find the folder: stale-xyz
// after
POST /projects/p1/folders { "name": "Root" } Defensive patterns
Strategy: validation
Validate before calling
async function parentExists(svc: FolderService, projectId: string, parentId?: string) {
if (!parentId) return true; // root
try { await svc.getFolderTree(parentId, projectId); return true; } catch { return false; }
}
// gate createFolder on parentExists(...) Type guard
const isCreateFolderDto = (p: unknown): p is { name: string; parentFolderId?: string } =>
typeof p === 'object' && p !== null && typeof (p as any).name === 'string'; Try / catch
try { await createFolder(payload, projectId); }
catch (e) { if (e instanceof NotFoundError && /Could not find the folder/.test(e.message)) { /* clear stale parent id */ } } Prevention
- Refresh the folder tree before showing the create dialog so parent IDs are current.
- Invalidate cached parent IDs when a folder is deleted.
- Default to root creation when the parent ID is uncertain.
When it happens
Trigger: POST `/projects/<projectId>/folders` with a `parentFolderId` (inside the `CreateFolderDto`) that does not exist in that project. The service lookup of the parent fails and surfaces as `FolderNotFoundError`.
Common situations: UI bug sending a stale parent ID; parent folder deleted between dialog open and submit; cross-project parent reference; manually crafted payloads with wrong IDs.
Related errors
- Project not found
- error.message
- Internal Server Error
- File not found: ${path}
- Down migration only possible when there are no projects. Ple
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/cf9cf783eb2a7b7f.
Report an issue: GitHub.