fix: add exist_ok=True to mkdir in BubblewrapEnvironment by hobostay · Pull Request #802 · SWE-agent/mini-swe-agent (original) (raw)
Summary
The mkdir call in BubblewrapEnvironment.__init__ was missing exist_ok=True, which is inconsistent with the rest of the codebase and could cause FileExistsError in rare edge cases.
Problem
In src/minisweagent/environments/extra/bubblewrap.py:79, the code calls:
self.working_dir.mkdir(parents=True)
While the directory name uses a UUID to minimize collision risk, there's a small chance that:
- UUID collision occurs (very rare but possible)
- An external process creates the same directory
- A previous run didn't clean up properly
In such cases, this would raise FileExistsError and fail initialization.
Solution
Add exist_ok=True to match the pattern used throughout the codebase:
self.working_dir.mkdir(parents=True, exist_ok=True)
Consistency
All other mkdir calls in the project use exist_ok=True:
src/minisweagent/__init__.py:27src/minisweagent/run/benchmarks/swebench.py:232src/minisweagent/agents/default.py:153
Test plan
- Existing tests in
tests/environments/extra/test_bubblewrap.pycontinue to pass - The fix is defensive - no behavior change in normal operation
🤖 Generated with Claude Code