{"record":{"id":"357a139cbc7302b0","repo":"usebruno/bruno","slug":"path-oldpath-is-not-a-valid-request-file","errorCode":null,"errorMessage":"path: ${oldPath} is not a valid request file","messagePattern":"path: (.+?) is not a valid request file","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":1156,"sourceCode":"         * Only then we need to use the temp dir approach to rename the folder\n         *\n         * Windows OS would sometimes throw error when renaming a folder with sub directories\n         * This is an alternative approach to avoid that error\n         */\n        if (isWindowsOSAndNotWSLPathAndItemHasSubDirectories) {\n          await fsExtra.copy(oldPath, tempDir);\n          await fsExtra.remove(oldPath);\n          await fsExtra.move(tempDir, newPath, { overwrite: true });\n          await fsExtra.remove(tempDir);\n        } else {\n          await fs.renameSync(oldPath, newPath);\n        }\n\n        return newPath;\n      }\n\n      if (!hasRequestExtension(oldPath, format)) {\n        throw new Error(`path: ${oldPath} is not a valid request file`);\n      }\n\n      if (!validateName(newFilename)) {\n        throw new Error(`path: ${newFilename} is not a valid filename`);\n      }\n\n      // update name in file and save new copy, then delete old copy\n      const data = await fs.promises.readFile(oldPath, 'utf8'); // Use async read\n      const jsonData = parseRequest(data, { format });\n      jsonData.name = newName;\n      moveRequestUid(oldPath, newPath);\n\n      const content = stringifyRequest(jsonData, { format });\n      await fs.promises.unlink(oldPath);\n      await writeFile(newPath, content);\n\n      return newPath;\n    } catch (error) {","sourceCodeStart":1138,"sourceCodeEnd":1174,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L1138-L1174","documentation":"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.","triggerScenarios":"Renaming the filename of an auxiliary file (.json, .md, .txt) or a file whose extension does not match the collection format detected by getCollectionFormat.","commonSituations":"Mixed-format collections, partial yml<->bru migration, or user selected a non-request file in the tree.","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."],"exampleFix":"// before\nawait window.Ipc.invoke('renderer:rename-item-filename', { oldPath: '/c/notes.md', newPath, newName, newFilename, collectionPathname });\n\n// after\nconst format = await window.Ipc.invoke('renderer:get-collection-format', collectionPathname);\nif (oldPath.endsWith(`.${format}`)) {\n  await window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath, newName, newFilename, collectionPathname });\n}","handlingStrategy":"validation","validationCode":"const format = await window.Ipc.invoke('renderer:get-collection-format', collectionPathname);\nconst expected = format === 'yml' ? '.yml' : '.bru';\nif (!oldPath.toLowerCase().endsWith(expected)) {\n  throw new Error(`source 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 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."],"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"}