{"record":{"id":"cc4276844ee75ddb","repo":"n8n-io/n8n","slug":"project-not-found","errorCode":null,"errorMessage":"Project not found","messagePattern":"Project not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"packages/cli/src/controllers/folder.controller.ts","lineNumber":53,"sourceCode":"export class ProjectController {\n\tconstructor(\n\t\tprivate readonly folderService: FolderService,\n\t\tprivate readonly enterpriseWorkflowService: EnterpriseWorkflowService,\n\t\tprivate readonly projectService: ProjectService,\n\t) {}\n\n\t@Middleware()\n\tasync validateProjectExists(\n\t\treq: AuthenticatedRequest<{ projectId: string }>,\n\t\tres: Response,\n\t\tnext: NextFunction,\n\t) {\n\t\ttry {\n\t\t\tconst { projectId } = req.params;\n\t\t\tawait this.projectService.getProject(projectId);\n\t\t\tnext();\n\t\t} catch (e) {\n\t\t\tres.status(404).send('Project not found');\n\t\t\treturn;\n\t\t}\n\t}\n\n\t@Post('/')\n\t@ProjectScope('folder:create')\n\t@Licensed('feat:folders')\n\tasync createFolder(\n\t\treq: AuthenticatedRequest<{ projectId: string }>,\n\t\t_res: Response,\n\t\t@Body payload: CreateFolderDto,\n\t) {\n\t\tconst { projectId } = req.params;\n\n\t\ttry {\n\t\t\tconst folder = await this.folderService.createFolder(payload, projectId);\n\t\t\treturn folder;\n\t\t} catch (e) {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/controllers/folder.controller.ts#L35-L71","documentation":"HTTP 404 with literal body 'Project not found' sent at folder.controller.ts:53 by the `validateProjectExists` middleware when `projectService.getProject(projectId)` throws (project missing or inaccessible in the current tenant). The middleware short-circuits with `res.status(404).send('Project not found')` before the route handler runs.","triggerScenarios":"Any folder route under a `:projectId` path where the project doesn't exist, was deleted, or isn't visible to the caller's scope. The middleware runs before `@ProjectScope` enforcement completes the lookup.","commonSituations":"Stale project ID in a bookmarked URL; project deleted between page load and folder action; cross-tenant access attempts; typos in manually constructed URLs.","solutions":["Verify the project exists and the caller has access: `GET /projects/<projectId>`.","Refresh the parent project list in the UI and re-issue the folder request against a valid ID.","Audit for deleted projects whose IDs still appear in client state/bookmarks."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async function projectExists(svc: ProjectService, id: string) {\n  try { await svc.getProject(id); return true; } catch { return false; }\n}\n// gate folder calls on projectExists(...)","typeGuard":null,"tryCatchPattern":"const r = await fetch(`/projects/${pid}/folders`);\nif (r.status === 404) { /* refresh project list, re-issue with valid pid */ }","preventionTips":["Cache the current project list and invalidate on project delete.","Validate :projectId at the client before any folder action.","Surface 404 'Project not found' as 'project was deleted' rather than a hard error."],"tags":["folders","projects","rest","not-found","middleware"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}