{"record":{"id":"e05e6cfb79a531fb","repo":"usebruno/bruno","slug":"path-oldpath-does-not-exist","errorCode":null,"errorMessage":"path: ${oldPath} does not exist","messagePattern":"path: (.+?) does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":1100,"sourceCode":"      jsonData.name = newName;\n      const content = stringifyRequest(jsonData, { format });\n      await writeFile(itemPath, content);\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  // rename item\n  ipcMain.handle('renderer:rename-item-filename', async (event, { oldPath, newPath, newName, newFilename, collectionPathname }) => {\n    const tempDir = path.join(os.tmpdir(), `temp-folder-${Date.now()}`);\n    const isWindowsOSAndNotWSLPathAndItemHasSubDirectories = isDirectory(oldPath) && isWindowsOS() && !isWSLPath(oldPath) && hasSubDirectories(oldPath);\n    try {\n      validatePathIsInsideCollection(oldPath);\n      validatePathIsInsideCollection(newPath);\n\n      // Check if the old path exists\n      if (!fs.existsSync(oldPath)) {\n        throw new Error(`path: ${oldPath} does not exist`);\n      }\n\n      if (!safeToRename(oldPath, newPath)) {\n        throw new Error(`path: ${newPath} already exists`);\n      }\n\n      const format = getCollectionFormat(collectionPathname);\n\n      if (isDirectory(oldPath)) {\n        const folderFilePath = path.join(oldPath, `folder.${format}`);\n        let folderFileJsonContent;\n        if (fs.existsSync(folderFilePath)) {\n          const oldFolderFileContent = await fs.promises.readFile(folderFilePath, 'utf8');\n          folderFileJsonContent = await parseFolder(oldFolderFileContent, { format });\n          folderFileJsonContent.meta.name = newName;\n        } else {\n          folderFileJsonContent = {\n            meta: {","sourceCodeStart":1082,"sourceCodeEnd":1118,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L1082-L1118","documentation":"Thrown by 'renderer:rename-item-filename' when fs.existsSync(oldPath) is false after the inside-collection validation. The handler changes the on-disk filename of an item, so the source must already exist.","triggerScenarios":"Renaming a file/folder that was removed between the UI action and the IPC call, or passing an oldPath from a stale collection tree.","commonSituations":"External deletion, git branch switch, sync conflict resolution, or the file was renamed once already and the UI still holds the old path.","solutions":["Refresh the tree and confirm oldPath exists before showing the rename dialog.","If the file was already renamed, update state and skip.","Watch for watcher 'unlink' events to invalidate stale paths in the UI."],"exampleFix":"// before\nawait window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath, newName, newFilename, collectionPathname });\n\n// after\nif (!(await window.ipc.invoke('main:path-exists', oldPath))) { await refreshTree(); return; }\nawait window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath, newName, newFilename, collectionPathname });","handlingStrategy":"validation","validationCode":"if (!(await window.ipc.invoke('main:path-exists', oldPath))) {\n  await refreshTree(); throw new Error('source item no longer exists');\n}\nawait window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath, newName, newFilename, collectionPathname });","typeGuard":"async function sourceExists(p: string): Promise<boolean> {\n  return Boolean(await window.ipc.invoke('main:path-exists', p));\n}","tryCatchPattern":"try {\n  await window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath, newName, newFilename, collectionPathname });\n} catch (e) {\n  if (String(e?.message).includes('does not exist')) { await refreshTree(); return; }\n  throw e;\n}","preventionTips":["Confirm oldPath exists before showing the rename dialog.","Invalidate stale tree paths on watcher 'unlink'.","Avoid queuing multiple rename actions on the same node."],"tags":["ipc","rename","filesystem","electron"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}