usebruno/bruno · warning · Error
folder: ${collectionPath} already exists
Error message
folder: ${collectionPath} already exists What it means
Thrown by 'renderer:clone-folder' when fs.existsSync(collectionPath) is true. The clone handler creates a new folder at collectionPath and refuses to overwrite an existing one.
Source
Thrown at packages/bruno-electron/src/ipc/collection.js:1549
failed: failedImports
}
});
}
return {
success: {
count: completedImports,
items: successfulImports
}
};
});
ipcMain.handle('renderer:clone-folder', async (event, itemFolder, collectionPath, collectionPathname) => {
try {
validatePathIsInsideCollection(collectionPath);
if (fs.existsSync(collectionPath)) {
throw new Error(`folder: ${collectionPath} already exists`);
}
const format = getCollectionFormat(collectionPathname);
// Recursive function to parse the folder and create files/folders
const parseCollectionItems = (items = [], currentPath) => {
items.forEach(async (item) => {
if (['http-request', 'graphql-request', 'grpc-request'].includes(item.type)) {
const content = await stringifyRequestViaWorker(item, { format });
// Use the correct file extension based on target format
const baseName = path.parse(item.filename).name;
const newFilename = format === 'yml' ? `${baseName}.yml` : `${baseName}.bru`;
const filePath = path.join(currentPath, newFilename);
safeWriteFileSync(filePath, content);
}
if (item.type === 'folder') {View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Generate a unique target name (e.g. 'folder-copy', 'folder-copy-2') before invoking clone.
- If the existing folder is a leftover from a failed clone, remove it or let the user choose a different destination.
- Surface the conflict and prompt for overwrite/rename/cancel.
Example fix
// before
await window.Ipc.invoke('renderer:clone-folder', itemFolder, targetPath, collectionPathname);
// after
let target = targetPath; let i = 1;
while (fs.existsSync(target)) target = `${targetPath}-copy-${i++}`;
await window.Ipc.invoke('renderer:clone-folder', itemFolder, target, collectionPathname); Defensive patterns
Strategy: validation
Validate before calling
let target = collectionPath; let i = 1;
while (await window.ipc.invoke('main:path-exists', target)) target = `${collectionPath}-copy-${i++}`;
await window.Ipc.invoke('renderer:clone-folder', itemFolder, target, collectionPathname); Type guard
async function targetIsClear(p: string): Promise<boolean> {
return !(await window.ipc.invoke('main:path-exists', p));
} Try / catch
try {
await window.Ipc.invoke('renderer:clone-folder', itemFolder, collectionPath, collectionPathname);
} catch (e) {
if (String(e?.message).includes('already exists')) {
const uniq = `${collectionPath}-copy-${Date.now()}`;
await window.Ipc.invoke('renderer:clone-folder', itemFolder, uniq, collectionPathname);
} else throw e;
} Prevention
- Pre-uniquify the target folder name.
- Prompt overwrite/rename on collision.
- Clean up partial folders from failed clones before retrying.
When it happens
Trigger: Cloning a folder into a destination where a folder of the same name already exists, or re-running a clone after a partial/interrupted earlier attempt that left the directory behind.
Common situations: Duplicate clone action, target name not uniquified, or a previous failed clone left a partial directory on disk.
Related errors
- path: ${newPath} already exists
- path: ${filePath} already exists
- ${request.filename} is not a valid filename
- A file with the name "${finalFilename}" already exists in th
- environment: ${newEnvFilePath} already exists
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/1d9ce9872d507854.
Report an issue: GitHub.