{"record":{"id":"69e303403f1ffb7f","repo":"usebruno/bruno","slug":"import-collection-failed","errorCode":null,"errorMessage":"Import collection failed","messagePattern":"Import collection failed","errorType":"exception","errorClass":"BrunoError","httpStatus":null,"severity":"error","filePath":"packages/bruno-app/src/utils/importers/bruno-collection.js","lineNumber":22,"sourceCode":"\nconst stripExportMetadata = (collection) => {\n  delete collection.exportedAt;\n  delete collection.exportedUsing;\n  return collection;\n};\n\nexport const processBrunoCollection = async (jsonData) => {\n  try {\n    let collection = stripExportMetadata(jsonData);\n    collection = hydrateSeqInCollection(collection);\n    collection = updateUidsInCollection(collection);\n    collection = transformItemsInCollection(collection);\n    collection = transformExampleStatusInCollection(collection);\n    await validateSchema(collection);\n    return collection;\n  } catch (err) {\n    console.error('Error processing Bruno collection:', err);\n    throw new BrunoError('Import collection failed');\n  }\n};\n\nexport const isBrunoCollection = (data) => {\n  // Check for Bruno collection format\n  if (typeof data !== 'object' || data === null) {\n    return false;\n  }\n\n  // Must have a version field that is a non-empty string\n  if (typeof data.version !== 'string' || !data.version.trim()) {\n    return false;\n  }\n\n  // Must have a name field that is a non-empty string\n  if (typeof data.name !== 'string' || !data.name.trim()) {\n    return false;\n  }","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-app/src/utils/importers/bruno-collection.js#L4-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pre-check the file with isBrunoCollection(data) before calling processBrunoCollection.","Confirm the file parses as JSON before processing.","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.","Match the Bruno version that produced the export, or re-export from the source."],"exampleFix":"// before\ntry {\n  ...\n  await validateSchema(collection);\n} catch (err) {\n  console.error('Error processing Bruno collection:', err);\n  throw new BrunoError('Import collection failed');\n}\n\n// after (pre-check + cause preservation in caller)\nimport { isBrunoCollection, processBrunoCollection } from 'utils/importers/bruno-collection';\nif (!isBrunoCollection(jsonData)) {\n  throw new BrunoError('File is not a valid Bruno collection (missing version/name/items)');\n}\nreturn processBrunoCollection(jsonData);","handlingStrategy":"type-guard","validationCode":"import { isBrunoCollection } from 'utils/importers/bruno-collection';\n\nif (!isBrunoCollection(jsonData)) {\n  throw new Error('File is not a valid Bruno collection (missing version/name/items)');\n}\nreturn processBrunoCollection(jsonData);","typeGuard":"import { isBrunoCollection } from 'utils/importers/bruno-collection';\n\n// returns true only for plausible Bruno collection shapes\nisBrunoCollection(data); // checks object, version string, name string, items array","tryCatchPattern":"try {\n  const collection = await processBrunoCollection(jsonData);\n} catch (e) {\n  // e is a BrunoError('Import collection failed'); schema cause is in console only\n  toast.error(e.message || 'Import collection failed');\n}","preventionTips":["Pre-check the file with isBrunoCollection(data) before processing.","Confirm JSON.parse succeeds before handing data to the pipeline.","Preserve the underlying cause via .cause so users see schema vs transform failures.","Re-export collections from a Bruno version matching the target when version drift is suspected."],"tags":["import","collection","schema-validation","bruno-error","error-masking"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}