{"record":{"id":"b41e2d8035ad45fc","repo":"usebruno/bruno","slug":"target-directory-targetdirname-does-not-exist","errorCode":null,"errorMessage":"Target directory: ${targetDirname} does not exist","messagePattern":"Target directory: (.+?) does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":591,"sourceCode":"\n      // Sync example UIDs cache to maintain consistency when examples are added/deleted/reordered\n      syncExampleUidsCache(pathname, request.examples);\n\n      const content = await stringifyRequestViaWorker(request, { format });\n      await writeFile(pathname, content);\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  ipcMain.handle('renderer:save-transient-request', async (event, { sourcePathname, targetDirname, targetFilename, request, format, sourceFormat }) => {\n    try {\n      if (!fs.existsSync(sourcePathname)) {\n        throw new Error(`Source path: ${sourcePathname} does not exist`);\n      }\n\n      if (!fs.existsSync(targetDirname)) {\n        throw new Error(`Target directory: ${targetDirname} does not exist`);\n      }\n\n      validatePathIsInsideCollection(targetDirname);\n\n      const collectionPath = findCollectionPathByItemPath(targetDirname);\n      if (!collectionPath) {\n        throw new Error('Could not determine collection for target directory');\n      }\n      const targetFormat = getCollectionFormat(collectionPath);\n\n      const filename = targetFilename || path.basename(sourcePathname);\n      const filenameWithoutExt = filename.replace(/\\.(bru|yml)$/, '');\n      const finalFilename = `${filenameWithoutExt}.${targetFormat}`;\n      const targetPathname = path.join(targetDirname, finalFilename);\n\n      if (fs.existsSync(targetPathname)) {\n        throw new Error(`A file with the name \"${finalFilename}\" already exists in the target location`);\n      }","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L573-L609","documentation":"Thrown by 'renderer:save-transient-request' when the target directory (targetDirname) does not exist. After confirming the source file exists, the handler ensures the destination directory is present before computing the final filename inside it.","triggerScenarios":"Saving a transient request into a folder that was deleted, not yet created, or supplied as a wrong path (e.g. a folder whose parent was renamed). Passing a targetDirname that points outside the collection tree.","commonSituations":"The target folder was removed between the UI render and the save. Drag-and-drop save into a folder that was just deleted by another tab. Wrong collection root selected in the move dialog.","solutions":["Re-read the collection tree to confirm the target folder still exists; recreate it if appropriate before saving.","If the folder was renamed/moved, resolve its current pathname and pass that as targetDirname.","Use 'renderer:create-folder' first if the intent is to save into a new folder."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const dirExists = await window.ipcRenderer.invoke('renderer:file-exists', targetDirname);\nif (!dirExists) {\n  // recreate the folder via renderer:create-folder, or pick a different target\n}","typeGuard":null,"tryCatchPattern":"try {\n  await window.ipcRenderer.invoke('renderer:save-transient-request', payload);\n} catch (e) {\n  if (/Target directory:.+does not exist/.test(e.message)) {\n    await window.ipcRenderer.invoke('renderer:create-folder', payload.targetDirname);\n    await window.ipcRenderer.invoke('renderer:save-transient-request', payload);\n  } else throw e;\n}","preventionTips":["Re-read the collection tree before showing the move/save dialog so target folders are current.","Create destination folders through the IPC before bulk-saving into them."],"tags":["ipc","filesystem","request","bruno"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}