{"record":{"id":"9622c1b3585eed6d","repo":"usebruno/bruno","slug":"filename-file-does-not-exist","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/collection.js","lineNumber":928,"sourceCode":"    } catch (error) {\n      console.error('Error creating .env file:', error);\n      return Promise.reject(error);\n    }\n  });\n\n  // Delete .env file for collection\n  ipcMain.handle('renderer:delete-dotenv-file', async (event, collectionPathname, filename = '.env') => {\n    try {\n      if (!isValidDotEnvFilename(filename)) {\n        throw new Error('Invalid .env filename');\n      }\n\n      validatePathIsInsideCollection(collectionPathname);\n\n      const dotEnvPath = path.join(collectionPathname, 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 .env file:', error);\n      return Promise.reject(error);\n    }\n  });\n\n  // update environment color\n  ipcMain.handle('renderer:update-environment-color', async (event, collectionPathname, environmentName, color) => {\n    try {\n      const format = getCollectionFormat(collectionPathname);\n      const envFilePath = resolveEnvironmentFilePath(collectionPathname, environmentName, format);\n\n      if (!fs.existsSync(envFilePath)) {","sourceCodeStart":910,"sourceCodeEnd":946,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L910-L946","documentation":"Thrown by the 'renderer:delete-dotenv-file' IPC handler when fs.existsSync() reports the resolved .env path is absent. Bruno deletes collection-scoped dotenv files (e.g. .env, .env.local) from disk via this handler, and it refuses to call fs.unlinkSync on a missing file. The filename is first validated by isValidDotEnvFilename (must be '.env' or start with '.env.'), so this error means the name was valid but the file is gone.","triggerScenarios":"Calling ipcRenderer.invoke('renderer:delete-dotenv-file', collectionPathname, filename) where filename passes isValidDotEnvFilename but path.join(collectionPathname, filename) does not exist on disk. Happens when the UI issues a delete after the file was already removed externally, after a rename, or when the collection directory was moved.","commonSituations":"User deleted the .env file outside Bruno (editor/terminal), the collection was relocated, a sync conflict removed it, or a duplicate delete request fired (double-click, stale UI state).","solutions":["Verify the file still exists with fs.existsSync(path.join(collectionPathname, filename)) before issuing delete, and treat missing-file as success (idempotent delete).","Refresh the collection/environment panel so the UI stops offering delete for files that no longer exist.","Check that collectionPathname points at the currently loaded collection and not a stale/copied path."],"exampleFix":"// before\nawait window.Ipc.invoke('renderer:delete-dotenv-file', collectionPathname, filename);\n\n// after\nconst fs = window.Ipc; // renderer has no fs; do existence check via a stat IPC or just make delete idempotent in the handler:\n// in collection.js handler:\nif (!fs.existsSync(dotEnvPath)) {\n  return { success: true, alreadyAbsent: true };\n}","handlingStrategy":"validation","validationCode":"// renderer side: confirm file exists before issuing delete\nconst fullPath = path.join(collectionPathname, filename);\nconst exists = await window.ipc.invoke('main:path-exists', fullPath);\nif (!exists) return { skipped: true, reason: 'already-absent' };\nawait window.Ipc.invoke('renderer:delete-dotenv-file', collectionPathname, filename);","typeGuard":"function isValidDotEnvName(filename: unknown): filename is string {\n  return typeof filename === 'string'\n    && (filename === '.env' || (/^\\.env\\.[a-zA-Z0-9._-]+$/.test(filename)));\n}","tryCatchPattern":"try {\n  await window.Ipc.invoke('renderer:delete-dotenv-file', collectionPathname, filename);\n} catch (e) {\n  if (String(e?.message).includes('does not exist')) return; // idempotent\n  throw e;\n}","preventionTips":["Treat 'file does not exist' on delete as success (idempotent) in the renderer.","Disable the delete control when the file is known to be absent.","Refresh the collection panel after external filesystem changes."],"tags":["ipc","filesystem","dotenv","electron","idempotency"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}