usebruno/bruno · warning · Error

path: is not a valid request file

Error message

path: ${itemPath} is not a valid request file

What it means

Thrown by 'renderer:rename-item-name' when itemPath is not a directory (folder branch skipped) and hasRequestExtension(itemPath, format) returns false — meaning the file does not end in .bru (or .yml for yml collections). Bruno only renames recognized request files via this branch.

Solutions

  1. Ensure the item's extension matches getCollectionFormat(collectionPathname) before invoking rename.
  2. If renaming a folder, confirm itemPath is a directory so the folder branch is taken instead.
  3. For non-request files, use a generic filesystem rename IPC rather than this handler.

Example fix

// before
await window.Ipc.invoke('renderer:rename-item-name', { itemPath: '/c/req.json', newName, collectionPathname });

// after
const format = await window.Ipc.invoke('renderer:get-collection-format', collectionPathname);
if (itemPath.endsWith(`.${format}`)) {
  await window.Ipc.invoke('renderer:rename-item-name', { itemPath, newName, 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 (!itemPath.toLowerCase().endsWith(expected)) {
  throw new Error(`item 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

When it happens

Trigger: Renaming a file with an extension other than the collection's format (e.g. renaming a .json or .md file, or a .bru file inside a yml-format collection), or passing a path with no extension.

Common situations: Mixed-format collections during partial migration, user picked an auxiliary file, or the format detection returned a different format than the file's actual extension.

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/c4bf384e7b168832. Report an issue: GitHub.

Appendix: source

Thrown at packages/bruno-electron/src/ipc/collection.js:1077

          folderFileJsonContent = await parseFolder(oldFolderFileContent, { format });
          folderFileJsonContent.meta.name = newName;
        } else {
          folderFileJsonContent = {
            meta: {
              name: newName
            }
          };
        }

        const folderFileContent = await stringifyFolder(folderFileJsonContent, { format });
        await writeFile(folderFilePath, folderFileContent);

        return;
      }

      const format = getCollectionFormat(collectionPathname);
      if (!hasRequestExtension(itemPath, format)) {
        throw new Error(`path: ${itemPath} is not a valid request file`);
      }

      const data = fs.readFileSync(itemPath, 'utf8');
      const jsonData = parseRequest(data, { format });
      jsonData.name = newName;
      const content = stringifyRequest(jsonData, { format });
      await writeFile(itemPath, content);
    } catch (error) {
      return Promise.reject(error);
    }
  });

  // rename item
  ipcMain.handle('renderer:rename-item-filename', async (event, { oldPath, newPath, newName, newFilename, collectionPathname }) => {
    const tempDir = path.join(os.tmpdir(), `temp-folder-${Date.now()}`);
    const isWindowsOSAndNotWSLPathAndItemHasSubDirectories = isDirectory(oldPath) && isWindowsOS() && !isWSLPath(oldPath) && hasSubDirectories(oldPath);
    try {
      validatePathIsInsideCollection(oldPath);

View on GitHub (pinned to 9bdd81c7bd)