{"record":{"id":"8096b3eba2712835","repo":"usebruno/bruno","slug":"folder-newfolderpath-already-exists","errorCode":null,"errorMessage":"folder: ${newFolderPath} already exists","messagePattern":"folder: (.+?) already exists","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":1751,"sourceCode":"    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  ipcMain.handle('renderer:move-folder-item', async (event, folderPath, destinationPath) => {\n    try {\n      validatePathIsInsideCollection(folderPath);\n      validatePathIsInsideCollection(destinationPath);\n\n      const folderName = path.basename(folderPath);\n      const newFolderPath = path.join(destinationPath, folderName);\n\n      if (!fs.existsSync(folderPath)) {\n        throw new Error(`folder: ${folderPath} does not exist`);\n      }\n\n      if (fs.existsSync(newFolderPath)) {\n        throw new Error(`folder: ${newFolderPath} already exists`);\n      }\n\n      const requestFilesAtSource = await searchForRequestFiles(folderPath);\n\n      for (let requestFile of requestFilesAtSource) {\n        const newRequestFilePath = requestFile.replace(folderPath, newFolderPath);\n        moveRequestUid(requestFile, newRequestFilePath);\n      }\n\n      fs.renameSync(folderPath, newFolderPath);\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  const writeBrunoConfig = async (brunoConfig, collectionPath, collectionRoot) => {\n    const transformedBrunoConfig = transformBrunoConfigBeforeSave(_.cloneDeep(brunoConfig));\n    const format = getCollectionFormat(collectionPath);","sourceCodeStart":1733,"sourceCodeEnd":1769,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L1733-L1769","documentation":"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.","triggerScenarios":"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.","commonSituations":"Duplicate folder name in destination, re-triggered drag-drop, or a prior interrupted move left the target folder.","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."],"exampleFix":"// before\nawait window.Ipc.invoke('renderer:move-folder-item', folderPath, destinationPath);\n\n// after\nconst folderName = path.basename(folderPath);\nlet dest = path.join(destinationPath, folderName); let i = 1;\nwhile (fs.existsSync(dest)) dest = path.join(destinationPath, `${folderName}-copy-${i++}`);\n// move handler derives newFolderPath from folderName internally, so rename source folder first or extend handler to accept an explicit target name","handlingStrategy":"validation","validationCode":"const folderName = path.basename(folderPath);\nconst newFolderPath = path.join(destinationPath, folderName);\nif (await window.ipc.invoke('main:path-exists', newFolderPath)) {\n  throw new Error(`a folder named '${folderName}' already exists in the destination`);\n}","typeGuard":"async function destinationIsClear(dest: string, folderName: string): Promise<boolean> {\n  return !(await window.ipc.invoke('main:path-exists', path.join(dest, folderName)));\n}","tryCatchPattern":"try {\n  await window.Ipc.invoke('renderer:move-folder-item', folderPath, destinationPath);\n} catch (e) {\n  if (String(e?.message).includes('already exists')) {\n    // rename source folder to a unique name first, then move\n    await renameAndRetryMove(folderPath, destinationPath);\n  } else throw e;\n}","preventionTips":["Pre-check the destination for same-named folders.","Offer merge/rename/cancel on collision.","Clean partial moves before retrying."],"tags":["ipc","move","folder","conflict","filesystem"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}