{"record":{"id":"d4f9f9d935175549","repo":"usebruno/bruno","slug":"path-newfilename-is-not-a-valid-filename","errorCode":null,"errorMessage":"path: ${newFilename} is not a valid filename","messagePattern":"path: (.+?) is not a valid filename","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":1160,"sourceCode":"         */\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) {\n      // in case the rename file operations fails, and we see that the temp dir exists\n      // and the old path does not exist, we need to restore the data from the temp dir to the old path\n      if (isWindowsOSAndNotWSLPathAndItemHasSubDirectories) {\n        if (fsExtra.pathExistsSync(tempDir) && !fsExtra.pathExistsSync(oldPath)) {","sourceCodeStart":1142,"sourceCodeEnd":1178,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L1142-L1178","documentation":"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]).","triggerScenarios":"Typing a filename with slashes, colons (common on Mac paste), trailing dots, leading spaces, reserved Windows names, or names longer than 255 characters.","commonSituations":"Cross-platform filename rules (user on macOS using ':' or '/'), copy-paste carrying illegal chars, or a script generating names with forbidden characters.","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."],"exampleFix":"// before\nawait window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath, newName, newFilename: 'my/request', collectionPathname });\n\n// after\nconst safe = newFilename.replace(/[<>:\"/\\\\|?*\\x00-\\x1F]/g, '_').replace(/^[\\s-]+/, '').replace(/[.\\s]+$/, '');\nawait window.Ipc.invoke('renderer:rename-item-filename', { oldPath, newPath: path.join(path.dirname(oldPath), safe), newName, newFilename: safe, collectionPathname });","handlingStrategy":"validation","validationCode":"function validateNameClient(name: string): boolean {\n  if (name.length > 255) return false;\n  if (/^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])$/i.test(name)) return false;\n  return /^[^\\s\\-<>:\"/\\\\|?*\\x00-\\x1F]/.test(name)\n    && /^[^<>:\"/\\\\|?*\\x00-\\x1F]*$/.test(name)\n    && /[^.\\s<>:\"/\\\\|?*\\x00-\\x1F]$/.test(name);\n}\nif (!validateNameClient(newFilename)) {\n  throw new Error('filename contains invalid characters');\n}","typeGuard":"function isValidFilename(name: unknown): name is string {\n  if (typeof name !== 'string' || name.length === 0 || name.length > 255) return false;\n  if (/^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])$/i.test(name)) return false;\n  return /^[^\\s\\-<>:\"/\\\\|?*\\x00-\\x1F]/.test(name)\n    && /^[^<>:\"/\\\\|?*\\x00-\\x1F]*$/.test(name)\n    && /[^.\\s<>:\"/\\\\|?*\\x00-\\x1F]$/.test(name);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["ipc","rename","filename","validation","cross-platform"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}