{"record":{"id":"4ffb7bedce8088e8","repo":"n8n-io/n8n","slug":"internal-server-error","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"exception","errorClass":"InternalServerError","httpStatus":500,"severity":"error","filePath":"packages/cli/src/controllers/folder.controller.ts","lineNumber":75,"sourceCode":"\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) {\n\t\t\tif (e instanceof FolderNotFoundError) {\n\t\t\t\tthrow new NotFoundError(e.message);\n\t\t\t}\n\t\t\tthrow new InternalServerError(undefined, e);\n\t\t}\n\t}\n\n\t@Get('/:folderId/tree')\n\t@ProjectScope('folder:read')\n\t@Licensed('feat:folders')\n\tasync getFolderTree(\n\t\treq: AuthenticatedRequest<{ projectId: string; folderId: string }>,\n\t\t_res: Response,\n\t) {\n\t\tconst { projectId, folderId } = req.params;\n\n\t\ttry {\n\t\t\tconst tree = await this.folderService.getFolderTree(folderId, projectId);\n\t\t\treturn tree;\n\t\t} catch (e) {\n\t\t\tif (e instanceof FolderNotFoundError) {\n\t\t\t\tthrow new NotFoundError(e.message);","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/controllers/folder.controller.ts#L57-L93","documentation":"InternalServerError (HTTP 500) thrown at folder.controller.ts:75 as the catch-all in `createFolder` for any non-`FolderNotFoundError` exception from `folderService.createFolder`. The message defaults to 'Internal Server Error' (the original error is attached as `cause` via `InternalServerError(undefined, e)`). Indicates an unexpected service-layer failure (DB, constraint, transaction).","triggerScenarios":"DB constraint violation (duplicate folder name under same parent), transaction failure, repository error, or any service bug during folder creation that is not a missing-folder case.","commonSituations":"Duplicate folder name where uniqueness is enforced; DB connection issues mid-request; partial transaction state after a crash; service-layer invariant violation.","solutions":["Inspect server logs for the original `cause` chained under the `InternalServerError`.","If duplicate-name: choose a different folder name or remove the conflicting folder.","If DB: verify DB connectivity and that the `folder` / `folder_relationship` tables are intact.","Reproduce with verbose logging (`N8N_LOG_LEVEL=debug`) to capture the wrapped error."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check for the most common cause: duplicate name under same parent\nasync function nameIsUnique(svc: FolderService, projectId: string, name: string, parentId?: string) {\n  const tree = await svc.getFolderTree(parentId ?? 'root', projectId);\n  return !tree.some((f: { name: string }) => f.name === name);\n}","typeGuard":"import { FolderNotFoundError } from '...';\nconst isFolderNotFound = (e: unknown): e is FolderNotFoundError => e instanceof FolderNotFoundError;","tryCatchPattern":"try { await createFolder(payload, projectId); }\ncatch (e) {\n  if (e instanceof FolderNotFoundError) throw new NotFoundError(e.message);\n  // everything else is InternalServerError — log e.cause, do not retry blindly\n  log.error('createFolder failed', { cause: e });\n}","preventionTips":["Distinguish duplicate-name from generic DB errors via the wrapped `cause`.","Keep DB connections healthy and monitor for transaction failures.","Add a service-layer uniqueness check before INSERT to give a cleaner error."],"tags":["folders","rest","internal-error","database"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}