fix(python): avoid FileAlreadyExistsException in venv cleanup#373
fix(python): avoid FileAlreadyExistsException in venv cleanup#373soul2zimate merged 2 commits intomainfrom
Conversation
Remove redundant Files.createFile() before Files.write() in PythonControllerVirtualEnv. Files.write() already creates the file if it doesn't exist. The createFile() call caused FileAlreadyExistsException when a previous analysis failed mid-way and left the requirements.txt behind in /tmp/trustify_da_env/. Implements TC-3894 Assisted-by: Claude Code
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan Review Summary by QodoRemove redundant file creation in Python venv cleanup
WalkthroughsDescription• Remove redundant Files.createFile() call before Files.write() • Files.write() already creates file if missing • Fixes FileAlreadyExistsException when retrying failed analyses • Prevents stale requirements.txt from causing race conditions Diagramflowchart LR
A["Previous: createFile + write"] -->|"FileAlreadyExistsException"| B["Failed on retry"]
C["Fixed: write only"] -->|"Auto-creates file"| D["Works on retry"]
File Changes1. src/main/java/io/github/guacsec/trustifyda/utils/PythonControllerVirtualEnv.java
|
Code Review by Qodo
1. TOCTOU write in /tmp
|
Test Results379 tests 379 ✅ 1m 36s ⏱️ Results for commit 1d6f4c5. ♻️ This comment has been updated with latest results. |
src/main/java/io/github/guacsec/trustifyda/utils/PythonControllerVirtualEnv.java
Show resolved
Hide resolved
CI Feedback 🧐(Feedback updated until commit 1d6f4c5)A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
Summary
Files.createFile()beforeFiles.write()inPythonControllerVirtualEnvFiles.write()already creates the file if it doesn't existcreateFile()call causedFileAlreadyExistsExceptionwhen a previous analysis failed mid-way and left therequirements.txtbehind in/tmp/trustify_da_env/Test plan
FileAlreadyExistsExceptionImplements TC-3894
🤖 Generated with Claude Code