Skip to content

🐛 Fix silent overwrite of main.py and README.md in current directory mode - #148

Open
Dextheking1 wants to merge 1 commit into
fastapi:mainfrom
Dextheking1:fix/no-silent-overwrite-current-dir
Open

Dextheking1 wants to merge 1 commit into
fastapi:mainfrom
Dextheking1:fix/no-silent-overwrite-current-dir

Conversation

@Dextheking1

Copy link
Copy Markdown

Running fastapi new with no arguments (or .) in a directory that already has a main.py and README.md but no pyproject.toml overwrites both files with the hello world template. No warning, no backup.

Subdirectory mode already refuses to touch an existing directory. Current directory mode had no check at all for the two files it writes.

Fix: in current directory mode, refuse to run when main.py or README.md already exist, with an error naming them.

Test: test_refuses_to_overwrite_existing_files_in_current_dir writes marker files, runs the CLI with no arguments, and asserts exit code 1 plus both files unchanged. It fails on current main (exit code 0, files replaced) and passes with this fix.

@Dextheking1
Dextheking1 marked this pull request as ready for review October 23, 2026 05:24
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