{"record":{"id":"33f180321f86859d","repo":"usebruno/bruno","slug":"environment-with-the-same-name-already-exists","errorCode":null,"errorMessage":"Environment with the same name already exists","messagePattern":"Environment with the same name already exists","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/store/global-environments.js","lineNumber":135,"sourceCode":"    if (!workspacePath) return;\n    const key = posixifyPath(workspacePath);\n    const mapping = this.store.get('activeGlobalEnvironmentUidByWorkspace', {});\n    delete mapping[key];\n    this.store.set('activeGlobalEnvironmentUidByWorkspace', mapping);\n  }\n\n  setGlobalEnvironments(globalEnvironments) {\n    globalEnvironments = this.filterValidEnvironments(globalEnvironments);\n\n    globalEnvironments = this.encryptGlobalEnvironmentVariables({ globalEnvironments });\n    return this.store.set('environments', globalEnvironments);\n  }\n\n  addGlobalEnvironment({ uid, name, variables = [], color }) {\n    let globalEnvironments = this.getGlobalEnvironments();\n    const existingEnvironment = globalEnvironments.find((env) => env?.name == name);\n    if (existingEnvironment) {\n      throw new Error('Environment with the same name already exists');\n    }\n    globalEnvironments.push({\n      uid,\n      name,\n      variables,\n      color\n    });\n    this.setGlobalEnvironments(globalEnvironments);\n  }\n\n  saveGlobalEnvironment({ environmentUid: globalEnvironmentUid, variables, color }) {\n    let globalEnvironments = this.getGlobalEnvironments();\n    const environment = globalEnvironments.find((env) => env?.uid == globalEnvironmentUid);\n    globalEnvironments = globalEnvironments.filter((env) => env?.uid !== globalEnvironmentUid);\n    if (environment) {\n      environment.variables = variables;\n      if (color !== undefined) {\n        environment.color = color;","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/store/global-environments.js#L117-L153","documentation":"Error \"Environment with the same name already exists\" thrown in usebruno/bruno.","triggerScenarios":"Thrown at packages/bruno-electron/src/store/global-environments.js:135 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a unique environment name.","Rename or delete the existing global environment first."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}