usebruno/bruno · warning · Error
path: ${oldPath} is not a valid request file
Error message
path: ${oldPath} is not a valid request file What it means
Thrown by 'renderer:rename-item-filename' when oldPath is not a directory (folder branch skipped) and hasRequestExtension(oldPath, format) is false. The handler only renames on-disk filenames for recognized request files in the non-directory branch.
Source
Thrown at packages/bruno-electron/src/ipc/collection.js:1156
* Only then we need to use the temp dir approach to rename the folder
*
* Windows OS would sometimes throw error when renaming a folder with sub directories
* This is an alternative approach to avoid that error
*/
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) {View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Confirm oldPath ends with the collection's format extension before invoking.
- Route non-request files through a generic rename path.
- If the item is actually a folder, ensure isDirectory(oldPath) is true so the folder branch runs.
Example fix
// before
await window.Ipc.invoke('renderer:rename-item-filename', { oldPath: '/c/notes.md', newPath, newName, newFilename, collectionPathname });
// after
const format = await window.Ipc.invoke('renderer:get-collection-format', collectionPathname);
if (oldPath.endsWith(`.${format}`)) {
await window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath, newName, newFilename, collectionPathname });
} Defensive patterns
Strategy: validation
Validate before calling
const format = await window.Ipc.invoke('renderer:get-collection-format', collectionPathname);
const expected = format === 'yml' ? '.yml' : '.bru';
if (!oldPath.toLowerCase().endsWith(expected)) {
throw new Error(`source must be a ${expected} request file`);
} Type guard
function hasRequestExtension(filename: string, format: 'bru' | 'yml'): boolean {
const ext = format === 'yml' ? 'yml' : 'bru';
return filename.toLowerCase().endsWith(`.${ext}`);
} Prevention
- Match the source extension to the collection format before renaming filename.
- Route non-request files through a generic rename.
- Detect folders so the folder branch handles them.
When it happens
Trigger: Renaming the filename of an auxiliary file (.json, .md, .txt) or a file whose extension does not match the collection format detected by getCollectionFormat.
Common situations: Mixed-format collections, partial yml<->bru migration, or user selected a non-request file in the tree.
Related errors
- path: ${itemPath} is not a valid request file
- path: ${newPath} already exists
- ${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/357a139cbc7302b0.
Report an issue: GitHub.