usebruno/bruno · error · Error
File ${filePath} is not a file
Error message
File ${filePath} is not a file What it means
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).
Source
Thrown at packages/bruno-electron/src/utils/filesystem.js:505
for (const entry of entries) {
const entryPath = path.join(source, entry);
await _getPaths(entryPath);
}
}
};
await _getPaths(source);
return paths;
};
/**
* Checks if a file is larger than a given threshold.
* @param {string} filePath - The path to the file.
* @param {number} threshold - The threshold in bytes. Default is 10MB.
* @returns {boolean} True if the file is larger than the threshold, false otherwise.
*/
const isLargeFile = (filePath, threshold = 10 * 1024 * 1024) => {
if (!isFile(filePath)) {
throw new Error(`File ${filePath} is not a file`);
}
const size = fs.statSync(filePath).size;
return size > threshold;
};
const isDotEnvFile = (pathname, collectionPath) => {
const dirname = path.dirname(pathname);
const basename = path.basename(pathname);
return path.normalize(dirname) === path.normalize(collectionPath) && basename === '.env';
};
const isValidDotEnvFilename = (filename) => {
if (!filename || typeof filename !== 'string') return false;
const basename = path.basename(filename);
if (basename !== filename) return false;View on GitHub (pinned to 9bdd81c7bd)
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.
Example fix
// before
const isLargeFile = (filePath, threshold = 10 * 1024 * 1024) => {
if (!isFile(filePath)) {
throw new Error(`File ${filePath} is not a file`);
}
...
};
// after: caller validates first
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) {
return { error: `Body file not found: ${filePath}` };
}
const large = isLargeFile(filePath, THRESHOLD); Defensive patterns
Strategy: validation
Validate before calling
function isReadableFile(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
}
if (!isReadableFile(filePath)) {
return { error: `Body file not found: ${filePath}` };
}
const large = isLargeFile(filePath, THRESHOLD); Type guard
function isRegularFile(filePath) {
try { return fs.statSync(filePath).isFile(); }
catch { return false; }
} Try / catch
try {
return isLargeFile(filePath, threshold);
} catch (err) {
if (err.message.includes('is not a file')) {
// body file missing; fall back to non-streaming send or re-prompt
return false;
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No files selected
- Invalid file type: ${file.name}. Only JSON files are support
- ${request.filename} is not a valid filename
- A file with the name "${finalFilename}" already exists in th
- environment: ${newEnvFilePath} already exists
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/58826e99e900fd43.
Report an issue: GitHub.