usebruno/bruno · warning · Error

Unsupported export format: ${exportFormat}

Error message

Unsupported export format: ${exportFormat}

What it means

Thrown by 'renderer:export-environment' when exportFormat is not one of the handled branches ('folder', 'single-object', and any earlier combined branch). The handler's final else clause catches any unrecognized format string.

Source

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

          environments
        };

        const jsonContent = JSON.stringify(exportData, null, 2);
        await fs.promises.writeFile(fullPath, jsonContent, 'utf8');
      } else if (exportFormat === 'single-object') {
        // single environment json file
        if (environments.length !== 1) {
          throw new Error('Single object export requires exactly one environment');
        }

        const environment = environments[0];
        const baseFileName = environment.name ? `${environment.name.replace(/[^a-zA-Z0-9-_]/g, '_')}` : 'environment';
        const uniqueFileName = generateUniqueName(baseFileName, (name) => fs.existsSync(path.join(filePath, `${name}.json`)));
        const fullPath = path.join(filePath, `${uniqueFileName}.json`);
        const jsonContent = JSON.stringify(environmentWithInfo(environment), null, 2);
        await fs.promises.writeFile(fullPath, jsonContent, 'utf8');
      } else {
        throw new Error(`Unsupported export format: ${exportFormat}`);
      }
    } catch (error) {
      return Promise.reject(error);
    }
  });

  // rename item
  ipcMain.handle('renderer:rename-item-name', async (event, { itemPath, newName, collectionPathname }) => {
    try {
      validatePathIsInsideCollection(itemPath);

      if (!fs.existsSync(itemPath)) {
        throw new Error(`path: ${itemPath} does not exist`);
      }

      if (isDirectory(itemPath)) {
        const format = getCollectionFormat(collectionPathname);
        const folderFilePath = path.join(itemPath, `folder.${format}`);

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Use only the format literals the handler recognizes ('folder', 'single-object'); default to 'folder' when unsure.
  2. Share a constant for exportFormat across renderer and main to avoid drift.
  3. Check the Bruno version's handler source for the accepted branches before adding a new option.

Example fix

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

// after
await window.Ipc.invoke('renderer:export-environment', { environments, environmentType, filePath, exportFormat: 'folder' });
Defensive patterns

Strategy: type-guard

Validate before calling

const EXPORT_FORMATS = new Set(['folder', 'single-object']);
const fmt = EXPORT_FORMATS.has(exportFormat) ? exportFormat : 'folder';
await window.Ipc.invoke('renderer:export-environment', { environments, environmentType, filePath, exportFormat: fmt });

Type guard

function isExportFormat(v: unknown): v is 'folder' | 'single-object' {
  return v === 'folder' || v === 'single-object';
}

Prevention

When it happens

Trigger: Passing exportFormat values like 'json', 'combined' (if not an implemented branch), 'single', undefined (when no default applies), or a typo'd literal.

Common situations: Caller refactored format names out of sync with the handler, used a value from an older/newer Bruno version, or sent undefined expecting the documented default 'folder'.

Related errors


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