{"record":{"id":"dc23201bea119ccb","repo":"usebruno/bruno","slug":"environment-newname-already-exists","errorCode":null,"errorMessage":"Environment \"${newName}\" already exists","messagePattern":"Environment \"(.+?)\" already exists","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/store/workspace-environments.js","lineNumber":219,"sourceCode":"    }\n  }\n\n  async renameGlobalEnvironment(workspacePath, { environmentUid, name: newName }) {\n    try {\n      if (!workspacePath) {\n        throw new Error('Workspace path is required');\n      }\n\n      const envFile = this.findEnvironmentFileByUid(workspacePath, environmentUid);\n\n      if (!envFile) {\n        throw new Error(`Environment file not found for uid: ${environmentUid}`);\n      }\n\n      const newFilePath = this.getEnvironmentFilePath(workspacePath, newName);\n\n      if (fs.existsSync(newFilePath) && newFilePath !== envFile.filePath) {\n        throw new Error(`Environment \"${newName}\" already exists`);\n      }\n\n      const environment = await this.parseEnvironmentFile(envFile.filePath, workspacePath);\n      const oldName = environment.name;\n      environment.name = newName;\n\n      const content = await stringifyEnvironment(environment, { format: 'yml' });\n      await writeFile(newFilePath, content);\n\n      if (this.envHasSecrets(environment)) {\n        const oldEnv = { name: oldName };\n        const secrets = environmentSecretsStore.getEnvSecrets(workspacePath, oldEnv);\n\n        if (secrets && secrets.length > 0) {\n          const newEnv = { name: newName, variables: environment.variables };\n          environmentSecretsStore.storeEnvSecrets(workspacePath, newEnv);\n        }\n      }","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/store/workspace-environments.js#L201-L237","documentation":"Error \"Environment \"${newName}\" already exists\" thrown in usebruno/bruno.","triggerScenarios":"Thrown at packages/bruno-electron/src/store/workspace-environments.js:219 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a new name that is not already used by another environment."],"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"}