{"record":{"id":"5e387dd01427ac87","repo":"usebruno/bruno","slug":"no-files-provided","errorCode":null,"errorMessage":"No files provided","messagePattern":"No files provided","errorType":"validation","errorClass":"BrunoError","httpStatus":null,"severity":"error","filePath":"packages/bruno-app/src/utils/importers/bruno-environment.js","lineNumber":81,"sourceCode":"const 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\nconst importBrunoEnvironment = (parsedFiles) => {\n  try {\n    if (!parsedFiles || parsedFiles.length === 0) {\n      throw new BrunoError('No files provided');\n    }\n\n    const environments = processFiles(parsedFiles);\n    return environments;\n  } catch (err) {\n    console.error(err);\n    throw err instanceof BrunoError ? err : new BrunoError('Import Bruno environment failed');\n  }\n};\n\nexport { importBrunoEnvironment, processEnvironmentData };\nexport default importBrunoEnvironment;\n","sourceCodeStart":63,"sourceCodeEnd":94,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-app/src/utils/importers/bruno-environment.js#L63-L94","documentation":"Entry guard in importBrunoEnvironment. Fires before any parsing when parsedFiles is null, undefined, or an empty array — i.e. the caller passed nothing to import.","triggerScenarios":"Calling importBrunoEnvironment([]), importBrunoEnvironment(null), or importBrunoEnvironment() directly. Upstream, this happens when readMultipleFiles receives no files or the file picker returns an empty selection that still reaches the importer.","commonSituations":"UI bug where the import flow proceeds despite no file selection, or programmatic use of the importer without first gathering files.","solutions":["Ensure at least one file is selected before invoking importBrunoEnvironment.","Guard upstream: check files?.length > 0 before calling readMultipleFiles.","Verify the file input's onChange handler actually populates the files list."],"exampleFix":"// before\nconst envs = importBrunoEnvironment(parsedFiles);\n// after\nif (!parsedFiles?.length) {\n  toast('Select at least one environment file');\n  return;\n}\nconst envs = importBrunoEnvironment(parsedFiles);","handlingStrategy":"validation","validationCode":"if (!parsedFiles || parsedFiles.length === 0) {\n  throw new Error('Select at least one environment file');\n}","typeGuard":"function hasFiles(files) {\n  return Array.isArray(files) && files.length > 0;\n}","tryCatchPattern":"try {\n  importBrunoEnvironment(parsedFiles);\n} catch (err) {\n  if (err.message === 'No files provided') toast('Choose a file first');\n  throw err;\n}","preventionTips":["Gate the import button on a non-empty file selection.","Check files?.length > 0 before calling readMultipleFiles or importBrunoEnvironment.","Test the import flow with zero files to confirm graceful handling."],"tags":["import","environment","validation","guard"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}