{"record":{"id":"e4adcdc1aa498d61","repo":"usebruno/bruno","slug":"workspace-path-is-required-e4adcd","errorCode":null,"errorMessage":"Workspace path is required","messagePattern":"Workspace path is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/ipc/global-environments.js","lineNumber":167,"sourceCode":"      const activeGlobalEnvironmentUid = workspacePath\n        ? await migrateActiveGlobalEnvironmentUid(workspacePath)\n        : globalEnvironmentsStore.getActiveGlobalEnvironmentUid();\n\n      return {\n        globalEnvironments,\n        activeGlobalEnvironmentUid\n      };\n    } catch (error) {\n      console.error('Error in renderer:get-global-environments:', error);\n      return Promise.reject(error);\n    }\n  });\n\n  // Save workspace .env file variables\n  ipcMain.handle('renderer:save-workspace-dotenv-variables', async (event, { workspacePath, variables, 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      const content = jsonToDotenv(variables);\n      await writeFile(dotEnvPath, content);\n\n      return { success: true };\n    } catch (error) {\n      console.error('Error saving workspace .env file:', error);\n      return Promise.reject(error);\n    }\n  });\n\n  // Save workspace .env file raw content","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/global-environments.js#L149-L185","documentation":"The IPC handler `renderer:save-workspace-dotenv-variables` writes a .env file inside a workspace and requires a `workspacePath`. If the renderer invokes the channel without one (undefined/empty) this throws before any filesystem access.","triggerScenarios":"Renderer calls `invoke('renderer:save-workspace-dotenv-variables', { variables })` omitting workspacePath; the workspace context isn't loaded yet when save fires; a stale ref passes null.","commonSituations":"UI race where the env editor mounts before the workspace is selected; a refactor that drops the workspace prop; testing the handler without a fixture.","solutions":["Pass the active workspace's absolute path from the call site.","Disable Save in the UI until workspacePath is truthy.","Ensure the workspace store hydrates before the env panel renders."],"exampleFix":"// before\nipcRenderer.invoke('renderer:save-workspace-dotenv-variables', { variables });\n// after\nipcRenderer.invoke('renderer:save-workspace-dotenv-variables', { workspacePath, variables });","handlingStrategy":"validation","validationCode":"const hasWorkspace = (wp) => typeof wp === 'string' && wp.trim().length > 0;\nif (!hasWorkspace(workspacePath)) throw new Error('Workspace path is required');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass workspacePath explicitly from the workspace store, never derive it implicitly.","Disable env-file actions in the UI until a workspace is active."],"tags":["workspace","env","ipc","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}