usebruno/bruno · error · Error
Target directory: ${targetDirname} does not exist
Error message
Target directory: ${targetDirname} does not exist What it means
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.
Source
Thrown at packages/bruno-electron/src/ipc/collection.js:591
// Sync example UIDs cache to maintain consistency when examples are added/deleted/reordered
syncExampleUidsCache(pathname, request.examples);
const content = await stringifyRequestViaWorker(request, { format });
await writeFile(pathname, content);
} catch (error) {
return Promise.reject(error);
}
});
ipcMain.handle('renderer:save-transient-request', async (event, { sourcePathname, targetDirname, targetFilename, request, format, sourceFormat }) => {
try {
if (!fs.existsSync(sourcePathname)) {
throw new Error(`Source path: ${sourcePathname} does not exist`);
}
if (!fs.existsSync(targetDirname)) {
throw new Error(`Target directory: ${targetDirname} does not exist`);
}
validatePathIsInsideCollection(targetDirname);
const collectionPath = findCollectionPathByItemPath(targetDirname);
if (!collectionPath) {
throw new Error('Could not determine collection for target directory');
}
const targetFormat = getCollectionFormat(collectionPath);
const filename = targetFilename || path.basename(sourcePathname);
const filenameWithoutExt = filename.replace(/\.(bru|yml)$/, '');
const finalFilename = `${filenameWithoutExt}.${targetFormat}`;
const targetPathname = path.join(targetDirname, finalFilename);
if (fs.existsSync(targetPathname)) {
throw new Error(`A file with the name "${finalFilename}" already exists in the target location`);
}View on GitHub (pinned to 9bdd81c7bd)
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.
Defensive patterns
Strategy: validation
Validate before calling
const dirExists = await window.ipcRenderer.invoke('renderer:file-exists', targetDirname);
if (!dirExists) {
// recreate the folder via renderer:create-folder, or pick a different target
} Try / catch
try {
await window.ipcRenderer.invoke('renderer:save-transient-request', payload);
} catch (e) {
if (/Target directory:.+does not exist/.test(e.message)) {
await window.ipcRenderer.invoke('renderer:create-folder', payload.targetDirname);
await window.ipcRenderer.invoke('renderer:save-transient-request', payload);
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ${request.filename} is not a valid filename
- path: ${pathname} does not exist
- Source path: ${sourcePathname} does not exist
- A file with the name "${finalFilename}" already exists in th
- Could not determine collection for target directory
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/b41e2d8035ad45fc.
Report an issue: GitHub.