{"record":{"id":"209f92135fe34061","repo":"usebruno/bruno","slug":"unsupported-environment-type-environmenttype","errorCode":null,"errorMessage":"Unsupported environment type: ${environmentType}","messagePattern":"Unsupported environment type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":972,"sourceCode":"        const updatedContent = stringifyEnvironment(environment, { format });\n        await writeFile(envFilePath, updatedContent);\n      });\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  // Generic environment export handler\n  ipcMain.handle('renderer:export-environment', async (event, { environments, environmentType, filePath, exportFormat = 'folder' }) => {\n    try {\n      if (!filePath || typeof filePath !== 'string' || !path.isAbsolute(filePath)) {\n        throw new Error('Export path must be an absolute directory path');\n      }\n      if (!fs.existsSync(filePath) || !isDirectory(filePath)) {\n        throw new Error(`Export path: ${filePath} is not an existing directory`);\n      }\n      if (environmentType !== 'collection' && environmentType !== 'global') {\n        throw new Error(`Unsupported environment type: ${environmentType}`);\n      }\n\n      const { app } = require('electron');\n      const appVersion = app?.getVersion() || '2.0.0';\n\n      // For single environments and folder exports, include info in each environment\n      const environmentWithInfo = (environment) => ({\n        name: environment.name,\n        variables: environment.variables,\n        color: environment.color ?? undefined,\n        info: {\n          type: 'bruno-environment',\n          exportedAt: new Date().toISOString(),\n          exportedUsing: `Bruno/v${appVersion}`\n        }\n      });\n\n      if (exportFormat === 'folder') {","sourceCodeStart":954,"sourceCodeEnd":990,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L954-L990","documentation":"Thrown by 'renderer:export-environment' when environmentType is neither 'collection' nor 'global'. The handler tags exported environments with their origin scope, and only those two literal values are accepted.","triggerScenarios":"Passing undefined, null, '', 'Collection' (wrong case), 'workspace', or any other string in the environmentType field of the export payload.","commonSituations":"Caller used a different casing or a translated label, refactored a constant out of sync with the handler's literals, or passed the wrong enum from a new UI surface.","solutions":["Pass exactly 'collection' or 'global' (lowercase) from a shared constant on the renderer side.","Define an environmentType union type and reuse it for both the picker and the IPC call.","Default to 'collection' when the source is ambiguous rather than passing an unknown value."],"exampleFix":"// before\nawait window.Ipc.invoke('renderer:export-environment', { environments, environmentType: 'Collection', filePath });\n\n// after\nconst ENV_TYPE = { COLLECTION: 'collection', GLOBAL: 'global' };\nawait window.Ipc.invoke('renderer:export-environment', { environments, environmentType: ENV_TYPE.COLLECTION, filePath });","handlingStrategy":"type-guard","validationCode":"const ENV_TYPES = new Set(['collection', 'global']);\nif (!ENV_TYPES.has(environmentType)) {\n  throw new Error(`environmentType must be 'collection' or 'global'`);\n}","typeGuard":"function isEnvironmentType(v: unknown): v is 'collection' | 'global' {\n  return v === 'collection' || v === 'global';\n}","tryCatchPattern":null,"preventionTips":["Centralize the allowed environmentType literals in a shared constant.","Drive the UI picker from that constant so casing never drifts.","Default to 'collection' rather than passing an unknown value."],"tags":["ipc","export","enum","validation","environment"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}