n8n-io/n8n · error · InternalServerError

Internal Server Error

Error message

Internal Server Error

What it means

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).

Source

Thrown at packages/cli/src/controllers/folder.controller.ts:75

	@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) {
			if (e instanceof FolderNotFoundError) {
				throw new NotFoundError(e.message);

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Inspect server logs for the original `cause` chained under the `InternalServerError`.
  2. If duplicate-name: choose a different folder name or remove the conflicting folder.
  3. If DB: verify DB connectivity and that the `folder` / `folder_relationship` tables are intact.
  4. Reproduce with verbose logging (`N8N_LOG_LEVEL=debug`) to capture the wrapped error.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check for the most common cause: duplicate name under same parent
async function nameIsUnique(svc: FolderService, projectId: string, name: string, parentId?: string) {
  const tree = await svc.getFolderTree(parentId ?? 'root', projectId);
  return !tree.some((f: { name: string }) => f.name === name);
}

Type guard

import { FolderNotFoundError } from '...';
const isFolderNotFound = (e: unknown): e is FolderNotFoundError => e instanceof FolderNotFoundError;

Try / catch

try { await createFolder(payload, projectId); }
catch (e) {
  if (e instanceof FolderNotFoundError) throw new NotFoundError(e.message);
  // everything else is InternalServerError — log e.cause, do not retry blindly
  log.error('createFolder failed', { cause: e });
}

Prevention

When it happens

Trigger: 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.

Common situations: Duplicate folder name where uniqueness is enforced; DB connection issues mid-request; partial transaction state after a crash; service-layer invariant violation.

Understand the failure class

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/4ffb7bedce8088e8. Report an issue: GitHub.