usebruno/bruno · warning · Error
folder: ${newFolderPath} already exists
Error message
folder: ${newFolderPath} already exists What it means
Thrown by 'renderer:move-folder-item' when fs.existsSync(newFolderPath) is true, where newFolderPath = destinationPath/<folderName>. The handler will not overwrite an existing folder at the destination, because it relies on fs.renameSync which would fail or clobber.
Source
Thrown at packages/bruno-electron/src/ipc/collection.js:1751
} catch (error) {
return Promise.reject(error);
}
});
ipcMain.handle('renderer:move-folder-item', async (event, folderPath, destinationPath) => {
try {
validatePathIsInsideCollection(folderPath);
validatePathIsInsideCollection(destinationPath);
const folderName = path.basename(folderPath);
const newFolderPath = path.join(destinationPath, folderName);
if (!fs.existsSync(folderPath)) {
throw new Error(`folder: ${folderPath} does not exist`);
}
if (fs.existsSync(newFolderPath)) {
throw new Error(`folder: ${newFolderPath} already exists`);
}
const requestFilesAtSource = await searchForRequestFiles(folderPath);
for (let requestFile of requestFilesAtSource) {
const newRequestFilePath = requestFile.replace(folderPath, newFolderPath);
moveRequestUid(requestFile, newRequestFilePath);
}
fs.renameSync(folderPath, newFolderPath);
} catch (error) {
return Promise.reject(error);
}
});
const writeBrunoConfig = async (brunoConfig, collectionPath, collectionRoot) => {
const transformedBrunoConfig = transformBrunoConfigBeforeSave(_.cloneDeep(brunoConfig));
const format = getCollectionFormat(collectionPath);View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Pre-check for a colliding destination folder and either merge, auto-rename, or prompt the user.
- Use generateUniqueName to derive a non-colliding destination folder name.
- Surface the conflict with replace/merge/cancel choices.
Example fix
// before
await window.Ipc.invoke('renderer:move-folder-item', folderPath, destinationPath);
// after
const folderName = path.basename(folderPath);
let dest = path.join(destinationPath, folderName); let i = 1;
while (fs.existsSync(dest)) dest = path.join(destinationPath, `${folderName}-copy-${i++}`);
// move handler derives newFolderPath from folderName internally, so rename source folder first or extend handler to accept an explicit target name Defensive patterns
Strategy: validation
Validate before calling
const folderName = path.basename(folderPath);
const newFolderPath = path.join(destinationPath, folderName);
if (await window.ipc.invoke('main:path-exists', newFolderPath)) {
throw new Error(`a folder named '${folderName}' already exists in the destination`);
} Type guard
async function destinationIsClear(dest: string, folderName: string): Promise<boolean> {
return !(await window.ipc.invoke('main:path-exists', path.join(dest, folderName)));
} Try / catch
try {
await window.Ipc.invoke('renderer:move-folder-item', folderPath, destinationPath);
} catch (e) {
if (String(e?.message).includes('already exists')) {
// rename source folder to a unique name first, then move
await renameAndRetryMove(folderPath, destinationPath);
} else throw e;
} Prevention
- Pre-check the destination for same-named folders.
- Offer merge/rename/cancel on collision.
- Clean partial moves before retrying.
When it happens
Trigger: Moving a folder into a destination that already contains a folder of the same name, or re-running a move after a partial earlier attempt.
Common situations: Duplicate folder name in destination, re-triggered drag-drop, or a prior interrupted move left the target folder.
Related errors
- A file with the name "${targetFilename}" already exists in t
- folder: ${folderPath} does not exist
- path: ${newPath} already exists
- folder: ${collectionPath} already exists
- path: ${filePath} already exists
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/8096b3eba2712835.
Report an issue: GitHub.