{"record":{"id":"e76a7db633a83143","repo":"usebruno/bruno","slug":"export-path-filepath-is-not-an-existing-direct","errorCode":null,"errorMessage":"Export path: ${filePath} is not an existing directory","messagePattern":"Export path: (.+?) is not an existing directory","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":969,"sourceCode":"        const fileContent = fs.readFileSync(envFilePath, 'utf8');\n        const environment = parseEnvironment(fileContent, { format });\n        environment.color = color;\n        const updatedContent = stringifyEnvironment(environment, { format });\n        await writeFile(envFilePath, updatedContent);\n      });\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  // Generic environment export handler\n  ipcMain.handle('renderer:export-environment', async (event, { environments, environmentType, filePath, exportFormat = 'folder' }) => {\n    try {\n      if (!filePath || typeof filePath !== 'string' || !path.isAbsolute(filePath)) {\n        throw new Error('Export path must be an absolute directory path');\n      }\n      if (!fs.existsSync(filePath) || !isDirectory(filePath)) {\n        throw new Error(`Export path: ${filePath} is not an existing directory`);\n      }\n      if (environmentType !== 'collection' && environmentType !== 'global') {\n        throw new Error(`Unsupported environment type: ${environmentType}`);\n      }\n\n      const { app } = require('electron');\n      const appVersion = app?.getVersion() || '2.0.0';\n\n      // For single environments and folder exports, include info in each environment\n      const environmentWithInfo = (environment) => ({\n        name: environment.name,\n        variables: environment.variables,\n        color: environment.color ?? undefined,\n        info: {\n          type: 'bruno-environment',\n          exportedAt: new Date().toISOString(),\n          exportedUsing: `Bruno/v${appVersion}`\n        }","sourceCodeStart":951,"sourceCodeEnd":987,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L951-L987","documentation":"Thrown by 'renderer:export-environment' after the absolute-path check passes but fs.existsSync(filePath) is false or isDirectory(filePath) is false. The handler will not write export files into a non-existent or file (non-directory) path.","triggerScenarios":"Passing an absolute path to a file instead of a folder, a path on a removable/unmounted drive, a deleted/moved directory, or a network share that is no longer mounted.","commonSituations":"User deleted/moved the target folder after picking it, chose a file path in an open-dialog that returns a file, removable media ejected, or SMB/NFS share dropped.","solutions":["Re-pick the directory via the folder dialog immediately before export.","Validate with fs.statSync(p).isDirectory() on the renderer side through a stat IPC, or surface the error and prompt re-selection.","Confirm the volume/share is mounted before retrying."],"exampleFix":"// before\nawait window.Ipc.invoke('renderer:export-environment', { environments, environmentType, filePath: staleDir });\n\n// after\nconst { filePath } = await window.ipc.invoke('main:select-directory');\nawait window.Ipc.invoke('renderer:export-environment', { environments, environmentType, filePath });","handlingStrategy":"validation","validationCode":"const stat = await window.ipc.invoke('main:stat', filePath);\nif (!stat || !stat.isDirectory()) {\n  throw new Error(`'${filePath}' is not an existing directory`);\n}","typeGuard":"function isExistingDirectory(stat: { isDirectory: () => boolean } | null): boolean {\n  return !!stat && typeof stat.isDirectory === 'function' && stat.isDirectory();\n}","tryCatchPattern":"try {\n  await window.Ipc.invoke('renderer:export-environment', payload);\n} catch (e) {\n  if (String(e?.message).includes('not an existing directory')) {\n    payload.filePath = await pickFolder(); await window.Ipc.invoke('renderer:export-environment', payload);\n  } else throw e;\n}","preventionTips":["Re-pick the directory right before exporting.","Watch for unmounted drives/shares.","Do not store export paths long-term in app state."],"tags":["ipc","export","filesystem","electron","directory"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}