{"record":{"id":"cb62ac3107400fe1","repo":"usebruno/bruno","slug":"path-filepath-already-exists","errorCode":null,"errorMessage":"path: ${filePath} already exists","messagePattern":"path: (.+?) already exists","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":2641,"sourceCode":"      throw error;\n    }\n  });\n\n  ipcMain.handle('renderer:export-collection-postman', async (event, dirPath, fileName, content, overwrite = false) => {\n    try {\n      if (!dirPath || !fs.existsSync(dirPath)) {\n        throw new Error('Export location does not exist');\n      }\n\n      // ensure the resolved path is inside the export directory\n      const resolvedDir = path.resolve(dirPath);\n      const filePath = path.resolve(resolvedDir, fileName);\n      if (!filePath.startsWith(resolvedDir + path.sep) && filePath !== resolvedDir) {\n        throw new Error('Invalid file name');\n      }\n\n      if (!overwrite && fs.existsSync(filePath)) {\n        throw new Error(`path: ${filePath} already exists`);\n      }\n\n      await writeFile(filePath, content);\n\n      return { success: true, filePath };\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  ipcMain.handle('renderer:is-bruno-collection-zip', async (event, zipFilePath) => {\n    try {\n      const zip = new AdmZip(zipFilePath);\n      const entries = zip.getEntries().map((e) => e.entryName);\n\n      return entries.some(\n        (name) =>\n          name === 'bruno.json'","sourceCodeStart":2623,"sourceCodeEnd":2659,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L2623-L2659","documentation":"renderer:export-collection-postman refuses to overwrite an existing file when the overwrite flag is false (the default). If fs.existsSync(filePath) is true after the traversal check passes, the export is aborted to prevent silent clobber.","triggerScenarios":"Calling renderer:export-collection-postman with overwrite=false (or omitted) when filePath already exists on disk.","commonSituations":"Repeated exports to the same location; previous export left behind; user picked a name that already exists.","solutions":["Pass overwrite=true if overwriting is intended.","Choose a unique fileName (append a timestamp or counter).","Delete the existing file before re-exporting."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const fs = require('fs');\nif (!overwrite && fs.existsSync(filePath)) {\n  // append a counter or prompt the user\n  throw new Error(`path: ${filePath} already exists`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ipcRenderer.invoke('renderer:export-collection-postman', dirPath, fileName, content, overwrite);\n} catch (err) {\n  if (/already exists/.test(err.message)) {\n    // prompt overwrite; retry with overwrite=true or a unique name\n  } else {\n    throw err;\n  }\n}","preventionTips":["Surface an explicit overwrite confirmation in the UI before re-calling with overwrite=true.","Auto-suffix duplicate exports with a timestamp to avoid the conflict."],"tags":["ipc","export","postman","filesystem","conflict","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}