Description
When running the migration utility on Windows, the user migration logic completes successfully, the utility displays an error when attempting to write to the log files on Windows. This is caused by the use of colons (:) in the generated filenames (e.g., migration-2026-02-13T20:45:14.log), which are reserved characters in Windows file systems (NTFS/FAT32).
Error Log
Error writing to log file:
fs.appendFileSync(fullPath, `${JSON.stringify(entry)}\n`);
^
ENOENT: no such file or directory, open '\\?\D:\Code\Clerk-migration-script\migration-script\logs\migration-2026-02-13T20:45:14.log'
path: "\\\\?\\D:\\Code\\Clerk-migration-script\\migration-script\\logs\\migration-2026-02-13T20:45:14.log",
syscall: "open",
errno: -2,
code: "ENOENT"
Steps to Reproduce
- Run
bun migrate on any Windows terminal (PowerShell, CMD, or Git Bash).
- The script successfully processes all users.
- The script shows error when
appendToLogFile attempts to write any entry to the log file.
- No log file is created.
Environment
- OS: Windows 10/11
- Runtime: Bun
- Version: Latest main branch
Proposed Fix
Sanitize the filePath within the appendToLogFile function in src/logger.ts to replace colons with dashes. This ensures cross-platform compatibility regardless of which logger function (error, validation, or import) is called.
File: src/logger.ts
function appendToLogFile(filePath: string, entry: unknown) {
try {
const logPath = getLogPath();
confirmOrCreateFolder(logPath);
// Sanitize file name for Windows compatibility
filePath = filePath.replace(/:/g, '-');
const fullPath = `${logPath}/${filePath}`;
fs.appendFileSync(fullPath, `${JSON.stringify(entry)}\n`);
} catch (err) {
console.error('Error writing to log file:', err);
}
}
I would be happy to open a Pull Request with this fix if the proposed solution looks good to the team!
Description
When running the migration utility on Windows, the user migration logic completes successfully, the utility displays an error when attempting to write to the log files on Windows. This is caused by the use of colons (:) in the generated filenames (e.g., migration-2026-02-13T20:45:14.log), which are reserved characters in Windows file systems (NTFS/FAT32).
Error Log
Steps to Reproduce
bun migrateon any Windows terminal (PowerShell, CMD, or Git Bash).appendToLogFileattempts to write any entry to the log file.Environment
Proposed Fix
Sanitize the
filePathwithin theappendToLogFilefunction insrc/logger.tsto replace colons with dashes. This ensures cross-platform compatibility regardless of which logger function (error, validation, or import) is called.File:
src/logger.tsI would be happy to open a Pull Request with this fix if the proposed solution looks good to the team!