usebruno/bruno · error · BrunoError

Import collection failed

Error message

Import collection failed

What it means

Thrown as a BrunoError('Import collection failed') by processBrunoCollection (bruno-collection.js:22). It wraps the whole import pipeline: stripExportMetadata, hydrateSeqInCollection, updateUidsInCollection, transformItemsInCollection, transformExampleStatusInCollection, and validateSchema. Any failure — most commonly validateSchema throwing BrunoError('The Collection file is corrupted') from a yup collectionSchema mismatch — is re-wrapped into this generic message, hiding the actual stage that failed.

Source

Thrown at packages/bruno-app/src/utils/importers/bruno-collection.js:22

const stripExportMetadata = (collection) => {
  delete collection.exportedAt;
  delete collection.exportedUsing;
  return collection;
};

export const processBrunoCollection = async (jsonData) => {
  try {
    let collection = stripExportMetadata(jsonData);
    collection = hydrateSeqInCollection(collection);
    collection = updateUidsInCollection(collection);
    collection = transformItemsInCollection(collection);
    collection = transformExampleStatusInCollection(collection);
    await validateSchema(collection);
    return collection;
  } catch (err) {
    console.error('Error processing Bruno collection:', err);
    throw new BrunoError('Import collection failed');
  }
};

export const isBrunoCollection = (data) => {
  // Check for Bruno collection format
  if (typeof data !== 'object' || data === null) {
    return false;
  }

  // Must have a version field that is a non-empty string
  if (typeof data.version !== 'string' || !data.version.trim()) {
    return false;
  }

  // Must have a name field that is a non-empty string
  if (typeof data.name !== 'string' || !data.name.trim()) {
    return false;
  }

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Pre-check the file with isBrunoCollection(data) before calling processBrunoCollection.
  2. Confirm the file parses as JSON before processing.
  3. Preserve the underlying cause: throw new BrunoError('Import collection failed', 'error') with the original err attached (e.g. via a .cause) so users see 'corrupted' vs 'transform' failures.
  4. Match the Bruno version that produced the export, or re-export from the source.

Example fix

// before
try {
  ...
  await validateSchema(collection);
} catch (err) {
  console.error('Error processing Bruno collection:', err);
  throw new BrunoError('Import collection failed');
}

// after (pre-check + cause preservation in caller)
import { isBrunoCollection, processBrunoCollection } from 'utils/importers/bruno-collection';
if (!isBrunoCollection(jsonData)) {
  throw new BrunoError('File is not a valid Bruno collection (missing version/name/items)');
}
return processBrunoCollection(jsonData);
Defensive patterns

Strategy: type-guard

Validate before calling

import { isBrunoCollection } from 'utils/importers/bruno-collection';

if (!isBrunoCollection(jsonData)) {
  throw new Error('File is not a valid Bruno collection (missing version/name/items)');
}
return processBrunoCollection(jsonData);

Type guard

import { isBrunoCollection } from 'utils/importers/bruno-collection';

// returns true only for plausible Bruno collection shapes
isBrunoCollection(data); // checks object, version string, name string, items array

Try / catch

try {
  const collection = await processBrunoCollection(jsonData);
} catch (e) {
  // e is a BrunoError('Import collection failed'); schema cause is in console only
  toast.error(e.message || 'Import collection failed');
}

Prevention

When it happens

Trigger: Malformed Bruno collection JSON: missing/invalid version or name, items not an array, request items failing the yup schema, or structural drift between the file's schema version and the current collectionSchema. Also thrown if uid/seq transformation hits an unexpected item shape.

Common situations: Importing a collection exported by a much older or newer Bruno version; hand-edited or partially-written JSON; a file that is technically JSON but not a valid Bruno collection.

Related errors


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