{"record":{"id":"b7414f10f6c1d0ef","repo":"usebruno/bruno","slug":"import-collection-failed-err-message-b7414f","errorCode":null,"errorMessage":"Import collection failed: ${err.message}","messagePattern":"Import collection failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-converters/src/postman/postman-to-bruno.js","lineNumber":1218,"sourceCode":"    const hydratedCollection = hydrateSeqInCollection(transformedCollection);\n    // Apply backward compatibility transformation for string status to number\n    const statusTransformedCollection = transformExampleStatusInCollection(hydratedCollection);\n    const validatedCollection = validateSchema(statusTransformedCollection);\n\n    // When preserving script option is enabled, skip any rewrite.\n    // Otherwise rewrite any pm.require() calls that survived the Bruno-side translator\n    // so the imported scripts use plain require(). The post-scan also picks\n    // up translator-injected globals (cheerio, tv4, ...) - packages Postman\n    // exposed as sandbox globals that the raw pre-scan can't see. The\n    // schema is strict + noUnknown so we attach the report by mutating\n    // the already-validated collection.\n    const injectedPackages = preserveScripts ? [] : rewriteRequiresInBrunoCollection(validatedCollection);\n    validatedCollection.packageReport = buildPackageReport([...rawPackages, ...injectedPackages]);\n\n    return { collection: validatedCollection, issues };\n  } catch (err) {\n    console.log(err);\n    throw new Error(`Import collection failed: ${err.message}`);\n  }\n};\n\nexport default postmanToBruno;\n","sourceCodeStart":1200,"sourceCodeEnd":1223,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-converters/src/postman/postman-to-bruno.js#L1200-L1223","documentation":"Thrown by the top-level postmanToBruno catch when any stage of the import pipeline fails. Unlike the inner normalizers, this wrapper preserves the original error's message via template literal (`err.message`), so it acts as a context-adding wrapper. Stages that can fail include package scanning, parsePostmanCollection, transformItemsInCollection, hydrateSeqInCollection, transformExampleStatusInCollection, validateSchema, and rewriteRequiresInBrunoCollection.","triggerScenarios":"Any uncaught error in the import pipeline: schema validation failure of the produced Bruno collection, a script-translation worker error bubbling up, a package-rewrite error, or one of the inner throws (errors 124/125) re-thrown here.","commonSituations":"Importing a large Postman collection with pre-request/test scripts the translator cannot handle; a collection that translates to a shape Bruno's schema rejects; filesystem/permission issues if scripts touch disk.","solutions":["Read the message suffix — the original err.message is appended and `console.log(err)` on line 1217 prints the full object; use it to identify the failing stage.","Retry with `{ preserveScripts: true }` to bypass script translation/rewriting and isolate whether scripts are the cause.","Retry with `{ useWorkers: false }` to run translation in-process for a clearer stack trace."],"exampleFix":"// before\nconst { collection } = await postmanToBruno(raw);\n\n// after — isolate the failing stage\ntry {\n  const { collection } = await postmanToBruno(raw, { preserveScripts: true, useWorkers: false });\n} catch (e) {\n  console.error('stage hint:', e.message);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await postmanToBruno(coll, { useWorkers: false, preserveScripts: false });\n} catch (e) {\n  // isolate: retry with preserveScripts to skip translation\n  if (preserveScriptsAvailable) {\n    return await postmanToBruno(coll, { preserveScripts: true });\n  }\n  throw e;\n}","preventionTips":["Use the preserveScripts/useWorkers options to isolate the failing pipeline stage.","Read the appended err.message — it identifies which sub-step failed.","Pre-validate the Postman collection structure (info.schema, item array) before import."],"tags":["postman","import","bruno-converters","error-wrapping","pipeline"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}