usebruno/bruno · error · Error

Unknown error

Error message

Unknown error

What it means

Thrown by the catch block of parseSwagger2Collection when an exception inside Swagger 2.0 parsing is NOT an instance of Error. The library uses this as a defensive guard: real Errors are rethrown as-is, but a non-Error throwable (string, plain object, or null) is normalized into a generic 'Unknown error'. The original cause is upstream in the parse pipeline; this message only surfaces when something threw a non-Error value.

Source

Thrown at packages/bruno-converters/src/openapi/swagger2-to-bruno.js:653

        }
        return folder;
      });

      let ungroupedItems = ungroupedRequests.map((req) => transformSwaggerRequestItem(req, usedNames, options));
      brunoCollection.items = brunoFolders.concat(ungroupedItems);
    }

    // Collection-level auth
    let collectionAuth = buildCollectionAuth(securityConfig.supported[0]);
    brunoCollection.root = {
      request: { auth: collectionAuth },
      meta: { name: brunoCollection.name },
      docs: toSpecString(collectionData.info?.description)
    };

    return brunoCollection;
  } catch (err) {
    if (!(err instanceof Error)) throw new Error('Unknown error');
    throw err;
  }
};

/**
 * Public API: Swagger 2.0 spec → validated Bruno collection
 * @param {Object} swaggerSpec - The Swagger 2.0 specification object
 * @param {Object} options - Import options
 * @returns {Object} Validated Bruno collection
 */
export const swagger2ToBruno = (swaggerSpec, options = {}) => {
  try {
    const collection = parseSwagger2Collection(swaggerSpec, options);
    const transformedCollection = transformItemsInCollection(collection);
    const hydratedCollection = hydrateSeqInCollection(transformedCollection);
    const validatedCollection = validateSchema(hydratedCollection);
    return validatedCollection;
  } catch (err) {

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Inspect the upstream call chain in parseSwagger2Collection and replace any `throw 'msg'` / `throw {..}` with `throw new Error(...)` so the real message survives.
  2. Reproduce with the exact swaggerSpec input and add a `console.error(err)` before line 653 to capture the non-Error value's shape.
  3. If you control the caller, ensure all rejected values are Error instances before they reach this function.

Example fix

// before (upstream helper)
if (!spec.host) throw 'Missing host';

// after
if (!spec.host) throw new Error('Swagger spec is missing required field: host');
Defensive patterns

Strategy: try-catch

Type guard

const isError = (e) => e instanceof Error;

Try / catch

try {
  const col = parseSwagger2Collection(spec);
} catch (err) {
  const real = err instanceof Error ? err : new Error(String(err));
  // surface real.message instead of the generic 'Unknown error'
  throw real;
}

Prevention

When it happens

Trigger: Any code path inside parseSwagger2Collection (or the functions it calls: buildCollectionAuth, transformSwaggerRequestItem, security resolution) that executes `throw <non-Error>` — e.g. a dependency throwing a string, a yup/array validation rejecting with a plain object, or an assertion library throwing a non-Error. It also fires if a Promise reject with a non-Error propagates synchronously into the try block.

Common situations: A malformed Swagger 2.0 spec where a deeply nested helper throws a raw string instead of an Error; third-party validators (ajv, yup) configured to throw plain objects; older Node behavior where certain native modules reject with strings.

Related errors


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