{"record":{"id":"4a9b831c7c1bc538","repo":"usebruno/bruno","slug":"filename-file-does-not-exist-4a9b83","errorCode":null,"errorMessage":"${filename} file does not exist","messagePattern":"(.+?) file does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/bruno-electron/src/ipc/global-environments.js","lineNumber":246,"sourceCode":"      return Promise.reject(error);\n    }\n  });\n\n  // Delete workspace .env file\n  ipcMain.handle('renderer:delete-workspace-dotenv-file', async (event, { workspacePath, filename = '.env' }) => {\n    try {\n      if (!workspacePath) {\n        throw new Error('Workspace path is required');\n      }\n\n      if (!isValidDotEnvFilename(filename)) {\n        throw new Error('Invalid .env filename');\n      }\n\n      const dotEnvPath = path.join(workspacePath, filename);\n\n      if (!fs.existsSync(dotEnvPath)) {\n        throw new Error(`${filename} file does not exist`);\n      }\n\n      fs.unlinkSync(dotEnvPath);\n\n      return { success: true };\n    } catch (error) {\n      console.error('Error deleting workspace .env file:', error);\n      return Promise.reject(error);\n    }\n  });\n\n  ipcMain.handle('renderer:update-global-environment-color', async (event, { environmentUid, color, workspacePath }) => {\n    try {\n      if (workspacePath && workspaceEnvironmentsManager) {\n        return await workspaceEnvironmentsManager.updateGlobalEnvironmentColorByPath(workspacePath, { environmentUid, color });\n      }\n\n      globalEnvironmentsStore.updateGlobalEnvironmentColor({ environmentUid, color });","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/global-environments.js#L228-L264","documentation":"In `renderer:delete-workspace-dotenv-file`, after validation, `fs.existsSync(dotEnvPath)` must be true before `fs.unlinkSync`. If the file isn't there the handler refuses rather than performing a silent no-op.","triggerScenarios":"Deleting a file that was removed externally; double-delete; the UI file list is out of sync with disk.","commonSituations":"The file was deleted outside Bruno; a previous delete already ran; refresh lag in the UI.","solutions":["Refresh the file list and only retry if the file is present.","Treat the error as success if the goal is simply 'ensure gone'.","Guard the call with an existence check and skip when already absent."],"exampleFix":"// before\nawait invoke('renderer:delete-workspace-dotenv-file', { workspacePath, filename: '.env' }); // throws if missing\n// after - idempotent delete\nif (fs.existsSync(path.join(workspacePath, '.env'))) {\n  await invoke('renderer:delete-workspace-dotenv-file', { workspacePath, filename: '.env' });\n}","handlingStrategy":"validation","validationCode":"const fs = require('fs'), path = require('path');\nconst exists = (workspacePath, filename) => fs.existsSync(path.join(workspacePath, filename));","typeGuard":null,"tryCatchPattern":"try {\n  await invoke('renderer:delete-workspace-dotenv-file', { workspacePath, filename });\n} catch (e) {\n  if (!/does not exist/i.test(e.message)) throw e; // idempotent: treat missing as success\n}","preventionTips":["Refresh disk state before delete actions.","Make delete idempotent in the UI by ignoring 'does not exist' errors.","Guard the call with an existence check and skip when already absent."],"tags":["env","filesystem","state-conflict","ipc"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}