{"record":{"id":"c4bf384e7b168832","repo":"usebruno/bruno","slug":"path-itempath-is-not-a-valid-request-file","errorCode":null,"errorMessage":"path: ${itemPath} is not a valid request file","messagePattern":"path: (.+?) is not a valid request file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":1077,"sourceCode":"          folderFileJsonContent = await parseFolder(oldFolderFileContent, { format });\n          folderFileJsonContent.meta.name = newName;\n        } else {\n          folderFileJsonContent = {\n            meta: {\n              name: newName\n            }\n          };\n        }\n\n        const folderFileContent = await stringifyFolder(folderFileJsonContent, { format });\n        await writeFile(folderFilePath, folderFileContent);\n\n        return;\n      }\n\n      const format = getCollectionFormat(collectionPathname);\n      if (!hasRequestExtension(itemPath, format)) {\n        throw new Error(`path: ${itemPath} is not a valid request file`);\n      }\n\n      const data = fs.readFileSync(itemPath, 'utf8');\n      const jsonData = parseRequest(data, { format });\n      jsonData.name = newName;\n      const content = stringifyRequest(jsonData, { format });\n      await writeFile(itemPath, content);\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  // rename item\n  ipcMain.handle('renderer:rename-item-filename', async (event, { oldPath, newPath, newName, newFilename, collectionPathname }) => {\n    const tempDir = path.join(os.tmpdir(), `temp-folder-${Date.now()}`);\n    const isWindowsOSAndNotWSLPathAndItemHasSubDirectories = isDirectory(oldPath) && isWindowsOS() && !isWSLPath(oldPath) && hasSubDirectories(oldPath);\n    try {\n      validatePathIsInsideCollection(oldPath);","sourceCodeStart":1059,"sourceCodeEnd":1095,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L1059-L1095","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the item's extension matches getCollectionFormat(collectionPathname) before invoking rename.","If renaming a folder, confirm itemPath is a directory so the folder branch is taken instead.","For non-request files, use a generic filesystem rename IPC rather than this handler."],"exampleFix":"// before\nawait window.Ipc.invoke('renderer:rename-item-name', { itemPath: '/c/req.json', newName, collectionPathname });\n\n// after\nconst format = await window.Ipc.invoke('renderer:get-collection-format', collectionPathname);\nif (itemPath.endsWith(`.${format}`)) {\n  await window.Ipc.invoke('renderer:rename-item-name', { itemPath, newName, collectionPathname });\n}","handlingStrategy":"validation","validationCode":"const format = await window.Ipc.invoke('renderer:get-collection-format', collectionPathname);\nconst expected = format === 'yml' ? '.yml' : '.bru';\nif (!itemPath.toLowerCase().endsWith(expected)) {\n  throw new Error(`item must be a ${expected} request file`);\n}","typeGuard":"function hasRequestExtension(filename: string, format: 'bru' | 'yml'): boolean {\n  const ext = format === 'yml' ? 'yml' : 'bru';\n  return filename.toLowerCase().endsWith(`.${ext}`);\n}","tryCatchPattern":null,"preventionTips":["Match the file extension to the collection format before rename.","Use the folder branch (or a generic rename) for non-request files.","Surface format info in the UI so users pick compatible items."],"tags":["ipc","rename","format","validation","filesystem"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}