{"record":{"id":"7833d7ab672a1739","repo":"usebruno/bruno","slug":"error-processing-filename-err-message","errorCode":null,"errorMessage":"Error processing ${fileName}: ${err.message}","messagePattern":"Error processing (.+?): (.+?)","errorType":"exception","errorClass":"BrunoError","httpStatus":null,"severity":"error","filePath":"packages/bruno-app/src/utils/importers/bruno-environment.js","lineNumber":59,"sourceCode":"        }\n      });\n    }\n\n    // Handle array of environments (old format)\n    if (Array.isArray(data)) {\n      return data.map((env, index) => {\n        try {\n          return validateBrunoEnvironment(env);\n        } catch (err) {\n          throw new BrunoError(`Error in environment ${index + 1} from ${fileName}: ${err.message}`);\n        }\n      });\n    }\n\n    // Handle single environment object\n    return [validateBrunoEnvironment(data)];\n  } catch (err) {\n    throw new BrunoError(`Error processing ${fileName}: ${err.message}`);\n  }\n};\n\nconst processFiles = (parsedFiles) => {\n  const allEnvironments = [];\n\n  for (const parsedFile of parsedFiles) {\n    try {\n      const environments = processEnvironmentData(parsedFile.content, parsedFile.fileName);\n      allEnvironments.push(...environments);\n    } catch (err) {\n      throw new BrunoError(`Failed to process ${parsedFile.fileName}: ${err.message}`);\n    }\n  }\n\n  return allEnvironments;\n};\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-app/src/utils/importers/bruno-environment.js#L41-L77","documentation":"Outer catch-all in processEnvironmentData. Fires when data is neither the new info.type format nor an array, and validateBrunoEnvironment(data) on the single-object path throws (errors 60-63), or when an unexpected exception escapes the inner handlers.","triggerScenarios":"Passing a single environment object that fails validation, or any non-array/non-bruno-environment payload that hits the fallback return [validateBrunoEnvironment(data)] line and throws.","commonSituations":"Importing a JSON object that looks like an environment but is malformed, or passing a completely different document type (e.g. a collection) into the environment importer.","solutions":["Check the inner message after 'Error processing <fileName>:' to find the root validateBrunoEnvironment cause.","Verify the file is intended as a Bruno environment, not a collection or Postman file.","Re-export a known-good environment and diff it against the failing file."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!isNewBrunoEnvironmentFile(data) && !Array.isArray(data)) {\n  if (!isBrunoEnvironment(data)) throw new Error('Single-object payload is not a valid environment');\n}","typeGuard":"function isAnyBrunoEnvironmentFormat(data) {\n  return isNewBrunoEnvironmentFile(data) || Array.isArray(data) || isBrunoEnvironment(data);\n}","tryCatchPattern":"try {\n  processEnvironmentData(data, fileName);\n} catch (err) {\n  // surface the inner 'Error processing <file>: <inner>' chain\n  throw err;\n}","preventionTips":["Confirm the file is a Bruno environment, not a collection or Postman file.","Validate the single-object payload structure before import.","Re-export a known-good environment and diff against the failing file."],"tags":["import","environment","error-wrapping"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}