usebruno/bruno · warning · Error
path: ${newFilename} is not a valid filename
Error message
path: ${newFilename} is not a valid filename What it means
Thrown by 'renderer:rename-item-filename' when validateName(newFilename) returns false. validateName rejects names containing <>:"/\|?* or control chars, names starting with space/hyphen, names ending with dot/space, names over 255 chars, and Windows reserved device names (CON, PRN, AUX, NUL, COM[0-9], LPT[0-9]).
Source
Thrown at packages/bruno-electron/src/ipc/collection.js:1160
*/
if (isWindowsOSAndNotWSLPathAndItemHasSubDirectories) {
await fsExtra.copy(oldPath, tempDir);
await fsExtra.remove(oldPath);
await fsExtra.move(tempDir, newPath, { overwrite: true });
await fsExtra.remove(tempDir);
} else {
await fs.renameSync(oldPath, newPath);
}
return newPath;
}
if (!hasRequestExtension(oldPath, format)) {
throw new Error(`path: ${oldPath} is not a valid request file`);
}
if (!validateName(newFilename)) {
throw new Error(`path: ${newFilename} is not a valid filename`);
}
// update name in file and save new copy, then delete old copy
const data = await fs.promises.readFile(oldPath, 'utf8'); // Use async read
const jsonData = parseRequest(data, { format });
jsonData.name = newName;
moveRequestUid(oldPath, newPath);
const content = stringifyRequest(jsonData, { format });
await fs.promises.unlink(oldPath);
await writeFile(newPath, content);
return newPath;
} catch (error) {
// in case the rename file operations fails, and we see that the temp dir exists
// and the old path does not exist, we need to restore the data from the temp dir to the old path
if (isWindowsOSAndNotWSLPathAndItemHasSubDirectories) {
if (fsExtra.pathExistsSync(tempDir) && !fsExtra.pathExistsSync(oldPath)) {View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Sanitize the proposed name (strip/replace forbidden chars) before invoking rename.
- Run the same validateName regex client-side to give inline feedback.
- Trim leading/trailing whitespace and dots, and reject names >255 chars in the UI.
Example fix
// before
await window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath, newName, newFilename: 'my/request', collectionPathname });
// after
const safe = newFilename.replace(/[<>:"/\\|?*\x00-\x1F]/g, '_').replace(/^[\s-]+/, '').replace(/[.\s]+$/, '');
await window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath: path.join(path.dirname(oldPath), safe), newName, newFilename: safe, collectionPathname }); Defensive patterns
Strategy: validation
Validate before calling
function validateNameClient(name: string): boolean {
if (name.length > 255) return false;
if (/^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])$/i.test(name)) return false;
return /^[^\s\-<>:"/\\|?*\x00-\x1F]/.test(name)
&& /^[^<>:"/\\|?*\x00-\x1F]*$/.test(name)
&& /[^.\s<>:"/\\|?*\x00-\x1F]$/.test(name);
}
if (!validateNameClient(newFilename)) {
throw new Error('filename contains invalid characters');
} Type guard
function isValidFilename(name: unknown): name is string {
if (typeof name !== 'string' || name.length === 0 || name.length > 255) return false;
if (/^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])$/i.test(name)) return false;
return /^[^\s\-<>:"/\\|?*\x00-\x1F]/.test(name)
&& /^[^<>:"/\\|?*\x00-\x1F]*$/.test(name)
&& /[^.\s<>:"/\\|?*\x00-\x1F]$/.test(name);
} Prevention
- Run the same validateName regex client-side for inline feedback.
- Sanitize pasted names (strip slashes, colons, control chars).
- Trim leading whitespace/hyphens and trailing dots/spaces.
When it happens
Trigger: Typing a filename with slashes, colons (common on Mac paste), trailing dots, leading spaces, reserved Windows names, or names longer than 255 characters.
Common situations: Cross-platform filename rules (user on macOS using ':' or '/'), copy-paste carrying illegal chars, or a script generating names with forbidden characters.
Related errors
- path: ${itemPath} is not a valid request file
- path: ${newPath} already exists
- path: ${oldPath} is not a valid request file
- Mock server id is required.
- Workspace path is required.
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/d4f9f9d935175549.
Report an issue: GitHub.