usebruno/bruno · error · Error

Unsupported environment type: ${environmentType}

Error message

Unsupported environment type: ${environmentType}

What it means

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.

Source

Thrown at packages/bruno-electron/src/ipc/collection.js:972

        const updatedContent = stringifyEnvironment(environment, { format });
        await writeFile(envFilePath, updatedContent);
      });
    } catch (error) {
      return Promise.reject(error);
    }
  });

  // Generic environment export handler
  ipcMain.handle('renderer:export-environment', async (event, { environments, environmentType, filePath, exportFormat = 'folder' }) => {
    try {
      if (!filePath || typeof filePath !== 'string' || !path.isAbsolute(filePath)) {
        throw new Error('Export path must be an absolute directory path');
      }
      if (!fs.existsSync(filePath) || !isDirectory(filePath)) {
        throw new Error(`Export path: ${filePath} is not an existing directory`);
      }
      if (environmentType !== 'collection' && environmentType !== 'global') {
        throw new Error(`Unsupported environment type: ${environmentType}`);
      }

      const { app } = require('electron');
      const appVersion = app?.getVersion() || '2.0.0';

      // For single environments and folder exports, include info in each environment
      const environmentWithInfo = (environment) => ({
        name: environment.name,
        variables: environment.variables,
        color: environment.color ?? undefined,
        info: {
          type: 'bruno-environment',
          exportedAt: new Date().toISOString(),
          exportedUsing: `Bruno/v${appVersion}`
        }
      });

      if (exportFormat === 'folder') {

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Pass exactly 'collection' or 'global' (lowercase) from a shared constant on the renderer side.
  2. Define an environmentType union type and reuse it for both the picker and the IPC call.
  3. Default to 'collection' when the source is ambiguous rather than passing an unknown value.

Example fix

// before
await window.Ipc.invoke('renderer:export-environment', { environments, environmentType: 'Collection', filePath });

// after
const ENV_TYPE = { COLLECTION: 'collection', GLOBAL: 'global' };
await window.Ipc.invoke('renderer:export-environment', { environments, environmentType: ENV_TYPE.COLLECTION, filePath });
Defensive patterns

Strategy: type-guard

Validate before calling

const ENV_TYPES = new Set(['collection', 'global']);
if (!ENV_TYPES.has(environmentType)) {
  throw new Error(`environmentType must be 'collection' or 'global'`);
}

Type guard

function isEnvironmentType(v: unknown): v is 'collection' | 'global' {
  return v === 'collection' || v === 'global';
}

Prevention

When it happens

Trigger: Passing undefined, null, '', 'Collection' (wrong case), 'workspace', or any other string in the environmentType field of the export payload.

Common situations: 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.

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/209f92135fe34061. Report an issue: GitHub.