Temporary folder cleanup error handling#11728
Conversation
|
🔒 Entelligence AI Vulnerability Scanner ❌ Security analysis failed: Security analysis failed: context deadline exceeded: This error is likely due to exceeding 'timeoutMs' — the total time a long running request (like process or directory watch) can be active. It can be modified by passing 'timeoutMs' when making the request. Use '0' to disable the timeout. |
| if file.is_dir(): | ||
| # https://docs.python.org/3/library/shutil.html#shutil.rmtree | ||
| shutil.rmtree(file, ignore_errors=True) |
There was a problem hiding this comment.
correctness: shutil.rmtree(file, ignore_errors=True) in clean_mindsdb_tmp_dir suppresses all errors, including critical ones like permission errors, which can leave the temp directory uncleared and mask real failures.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In mindsdb/__main__.py, lines 177-179, the use of `shutil.rmtree(file, ignore_errors=True)` in `clean_mindsdb_tmp_dir` suppresses all errors, including critical ones (e.g., permission errors), which can leave the temp directory uncleared and mask real failures. Replace this with a try/except block that calls `shutil.rmtree(file)` and logs any exceptions, so that real errors are not silently ignored.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| if file.is_dir(): | |
| # https://docs.python.org/3/library/shutil.html#shutil.rmtree | |
| shutil.rmtree(file, ignore_errors=True) | |
| if file.is_dir(): | |
| # https://docs.python.org/3/library/shutil.html#shutil.rmtree | |
| try: | |
| shutil.rmtree(file) | |
| except Exception as e: | |
| logger.error(f"Failed to remove directory {file}: {e}") |
ZoranPandovski
left a comment
There was a problem hiding this comment.
Thanks, I've added two minor comments
ZoranPandovski
left a comment
There was a problem hiding this comment.
Please check the ruff format warnings
hamishfagg
left a comment
There was a problem hiding this comment.
Same as other PRs, comment in check_requirements.py
|
All contributors have signed the CLA ✍️ ✅ |
d55b7e3 to
cae2b22
Compare
Description
This PR is adding error handling in the clean mindsdb tmp dir if errors are occurring.
Additionally i have added tests to cover the change
Type of change
(Please delete options that are not relevant)
Verification Process
To ensure the changes are working as expected:
tests/unit/various/test_main.pyAdditional Media:
Checklist: