Skip to content

fix: use Path.replace() for Windows compatibility#74

Merged
cmworkato merged 1 commit intomainfrom
fix/windows-file-rename-error
Mar 3, 2026
Merged

fix: use Path.replace() for Windows compatibility#74
cmworkato merged 1 commit intomainfrom
fix/windows-file-rename-error

Conversation

@cmworkato
Copy link
Contributor

Summary

Fixes FileExistsError on Windows when running workato init.

Problem

On Windows, Path.rename() fails with [WinError 183] Cannot create a file when that file already exists when the destination file exists. This happens during workato init because save_profiles() is called multiple times (once to save profile data, once to set it as current).

Solution

Changed temp_file.rename(self.profiles_file) to temp_file.replace(self.profiles_file).

Path.replace() works identically to rename() but will overwrite the destination file if it exists, which is the expected behavior for atomic write patterns.

Testing

  • Added unit test test_save_profiles_overwrites_existing to verify consecutive saves work correctly

Path.rename() fails on Windows when destination exists (FileExistsError).
Path.replace() works cross-platform and overwrites existing files.

Added test to verify overwriting existing profiles file works.
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py68494%10–11, 69–70
cli
   __init__.py52394%49, 51, 60
   containers.py270100% 
cli/commands
   __init__.py00100% 
   api_clients.py291996%27, 302, 448–449, 483, 493, 584, 615, 623
   api_collections.py257398%28, 183, 347
   assets.py47295%57–58
   connections.py526599%596, 598, 604, 642, 993
   data_tables.py165596%31, 253, 267, 321–322
   guide.py166199%106
   init.py1080100% 
   profiles.py3512892%353, 370, 372–373, 376, 378, 381–384, 386–387, 389, 460–461, 541–542, 544–545, 547–548, 552, 556–557, 567–569, 622
   properties.py97198%21
   pull.py172298%193–194
   workspace.py39294%61, 71
cli/commands/connectors
   __init__.py00100% 
   command.py103298%131, 180
   connector_manager.py203498%176, 292, 300–301
cli/commands/projects
   __init__.py00100% 
   command.py2721096%359–362, 373, 439–441, 491, 495
   project_manager.py166795%48, 66, 263–264, 276, 317, 325
cli/commands/push
   __init__.py00100% 
   command.py133496%109, 112, 230, 308
cli/commands/recipes
   __init__.py00100% 
   command.py427997%117, 133–134, 272–275, 403, 709
   validator.py7062097%174, 883, 1136, 1223, 1246, 1279, 1281–1282, 1359–1361, 1457–1458, 1517–1518, 1707–1708, 1736–1738
cli/utils
   __init__.py40100% 
   exception_handler.py3453390%134–135, 140–141, 143–144, 174–175, 181, 184–185, 270, 300, 333–337, 371, 398, 425, 482, 517, 576, 578–579, 584–585, 587–591
   gitignore.py140100% 
   ignore_patterns.py230100% 
   spinner.py430100% 
   token_input.py451762%70, 98, 100, 102–104, 107, 124, 127–128, 132–133, 136, 139–140, 142, 144
   version_checker.py135695%24, 26, 33–34, 72, 102
cli/utils/config
   __init__.py50100% 
   manager.py5373393%130, 141, 152, 160–162, 165, 168, 180, 230–231, 404, 422, 426, 429–432, 448, 469, 483, 496, 538, 640–641, 680, 894, 1037–1038, 1052–1053, 1109, 1168
   models.py330100% 
   profiles.py3341595%99, 195–196, 199, 234–236, 261–263, 522, 530, 541–542, 546
   workspace.py680100% 
TOTAL596222596% 

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@cmworkato cmworkato requested a review from oalami March 3, 2026 19:51
@cmworkato cmworkato merged commit 54896f4 into main Mar 3, 2026
10 checks passed
@cmworkato cmworkato deleted the fix/windows-file-rename-error branch March 3, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants