usebruno/bruno · error · Error

Invalid Postman collection format. Please check your JSON fi

Error message

Invalid Postman collection format. Please check your JSON file.

What it means

Thrown by the catch block of parsePostmanCollection when an exception inside the try is NOT an Error instance. This mirrors the error-normalization pattern: genuine Errors (including the 'Unsupported schema' one from error 124) are rethrown as-is, but any non-Error throwable (string, plain object) is converted to a generic 'Invalid Postman collection format' message. It is the defensive fallback for non-Error throwables escaping schema detection/import.

Source

Thrown at packages/bruno-converters/src/postman/postman-to-bruno.js:1185

    let v2Schemas = [
      'https://schema.getpostman.com/json/collection/v2.0.0/collection.json',
      'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',
      'https://schema.postman.com/json/collection/v2.0.0/collection.json',
      'https://schema.postman.com/json/collection/v2.1.0/collection.json'
    ];

    if (v2Schemas.includes(schema)) {
      return await importPostmanV2Collection(parsedCollection, { useWorkers, preserveScripts });
    }

    throw new Error('Unsupported Postman schema version. Only Postman Collection v2.0 and v2.1 are supported.');
  } catch (err) {
    console.log(err);
    if (err instanceof Error) {
      throw err;
    }

    throw new Error('Invalid Postman collection format. Please check your JSON file.');
  }
};

const postmanToBruno = async (postmanCollection, { useWorkers = false, preserveScripts = false } = {}) => {
  try {
    // Resolve the actual collection envelope (Postman wraps newer exports
    // in a `{ collection: {...} }` shell) so the raw scan sees real events.
    const rawCollectionForScan = postmanCollection?.collection?.info
      ? postmanCollection.collection
      : postmanCollection;
    const rawPackages = collectPackagesFromPostmanCollection(rawCollectionForScan);

    const { collection: parsedCollection, issues } = await parsePostmanCollection(postmanCollection, { useWorkers, preserveScripts });
    const transformedCollection = transformItemsInCollection(parsedCollection);
    const hydratedCollection = hydrateSeqInCollection(transformedCollection);
    // Apply backward compatibility transformation for string status to number
    const statusTransformedCollection = transformExampleStatusInCollection(hydratedCollection);
    const validatedCollection = validateSchema(statusTransformedCollection);

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Check stdout — `console.log(err)` on line 1180 prints the original non-Error value.
  2. Validate the JSON is parseable and structurally Postman-v2 before calling the importer.
  3. Patch internal throw sites to use Error instances so the real message reaches the caller.

Example fix

// before (inside importer)
if (!item.request) throw 'missing request';

// after
if (!item.request) throw new Error('Postman item is missing a request block: ' + item.name);
Defensive patterns

Strategy: try-catch

Type guard

const isPlainPostmanCollection = (c) => !!c && typeof c === 'object' && Array.isArray((c.collection?.info ? c.collection : c).item);

Try / catch

try {
  return await parsePostmanCollection(coll, opts);
} catch (e) {
  // real err is console.logged by the wrapper
  throw e instanceof Error ? e : new Error(String(e));
}

Prevention

When it happens

Trigger: importPostmanV2Collection (or get/collectPackagesFromPostmanCollection) throwing a non-Error value; a JSON-parsed structure causing a library to reject with a plain object; a circular reference producing a non-Error throw.

Common situations: Corrupt or truncated Postman JSON that a dependency rejects with a string; collection with circular $ref structures; third-party translator code doing `throw { detail: ... }`.

Related errors


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