{"record":{"id":"58826e99e900fd43","repo":"usebruno/bruno","slug":"file-filepath-is-not-a-file-58826e","errorCode":null,"errorMessage":"File ${filePath} is not a file","messagePattern":"File (.+?) is not a file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/utils/filesystem.js","lineNumber":505,"sourceCode":"      for (const entry of entries) {\n        const entryPath = path.join(source, entry);\n        await _getPaths(entryPath);\n      }\n    }\n  };\n  await _getPaths(source);\n  return paths;\n};\n\n/**\n * Checks if a file is larger than a given threshold.\n * @param {string} filePath - The path to the file.\n * @param {number} threshold - The threshold in bytes. Default is 10MB.\n * @returns {boolean} True if the file is larger than the threshold, false otherwise.\n */\nconst isLargeFile = (filePath, threshold = 10 * 1024 * 1024) => {\n  if (!isFile(filePath)) {\n    throw new Error(`File ${filePath} is not a file`);\n  }\n\n  const size = fs.statSync(filePath).size;\n\n  return size > threshold;\n};\n\nconst isDotEnvFile = (pathname, collectionPath) => {\n  const dirname = path.dirname(pathname);\n  const basename = path.basename(pathname);\n\n  return path.normalize(dirname) === path.normalize(collectionPath) && basename === '.env';\n};\n\nconst isValidDotEnvFilename = (filename) => {\n  if (!filename || typeof filename !== 'string') return false;\n  const basename = path.basename(filename);\n  if (basename !== filename) return false;","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/utils/filesystem.js#L487-L523","documentation":"Thrown by isLargeFile when isFile(filePath) returns false. isLargeFile is meant to size-check a regular file before streaming; the guard rejects missing paths and directories (neither of which has a meaningful file size for this check).","triggerScenarios":"Calling isLargeFile on a path that does not exist, or on a directory; used in prepare-request.js for streaming request bodies, so this fires when the configured file path is wrong or the user pointed at a folder.","commonSituations":"Request body file moved/deleted since the request was saved; user selected a directory instead of a file in the picker; path stored with a typo or wrong casing on a case-sensitive FS.","solutions":["Verify fs.existsSync(filePath) && fs.statSync(filePath).isFile() before calling isLargeFile.","Re-resolve the file path from the UI when the body file cannot be found.","Treat a missing body file as a user-facing validation error rather than letting isLargeFile throw mid-request."],"exampleFix":"// before\nconst isLargeFile = (filePath, threshold = 10 * 1024 * 1024) => {\n  if (!isFile(filePath)) {\n    throw new Error(`File ${filePath} is not a file`);\n  }\n  ...\n};\n\n// after: caller validates first\nif (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) {\n  return { error: `Body file not found: ${filePath}` };\n}\nconst large = isLargeFile(filePath, THRESHOLD);","handlingStrategy":"validation","validationCode":"function isReadableFile(filePath) {\n  return fs.existsSync(filePath) && fs.statSync(filePath).isFile();\n}\nif (!isReadableFile(filePath)) {\n  return { error: `Body file not found: ${filePath}` };\n}\nconst large = isLargeFile(filePath, THRESHOLD);","typeGuard":"function isRegularFile(filePath) {\n  try { return fs.statSync(filePath).isFile(); }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  return isLargeFile(filePath, threshold);\n} catch (err) {\n  if (err.message.includes('is not a file')) {\n    // body file missing; fall back to non-streaming send or re-prompt\n    return false;\n  }\n  throw err;\n}","preventionTips":["Validate the file path with statSync().isFile() before calling isLargeFile.","Re-resolve body file paths from the UI when they go missing.","Treat a missing body file as user-facing validation, not a runtime crash."],"tags":["filesystem","request-body","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}