Skip to content

Temporary folder cleanup error handling#11728

Merged
tino097 merged 17 commits into
mindsdb:releases/26.1.0from
tino097:bugfix/temporary-folder-cleanup
Apr 3, 2026
Merged

Temporary folder cleanup error handling#11728
tino097 merged 17 commits into
mindsdb:releases/26.1.0from
tino097:bugfix/temporary-folder-cleanup

Conversation

@tino097

@tino097 tino097 commented Oct 12, 2025

Copy link
Copy Markdown
Contributor

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)

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Verification Process

To ensure the changes are working as expected:

  • Test Location: tests/unit/various/test_main.py
  • Verification Steps: Outline the steps or queries needed to validate the change. Include any data, configurations, or actions required to reproduce or see the new functionality.

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

@tino097 tino097 changed the title Bugfix/temporary folder cleanup Temporary folder cleanup Oct 12, 2025
@tino097 tino097 changed the title Temporary folder cleanup Temporary folder cleanup error handling Oct 12, 2025
@entelligence-ai-pr-reviews

Copy link
Copy Markdown
Contributor

🔒 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.

Comment thread mindsdb/__main__.py Outdated
Comment on lines +177 to +179
if file.is_dir():
# https://docs.python.org/3/library/shutil.html#shutil.rmtree
shutil.rmtree(file, ignore_errors=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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 ZoranPandovski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've added two minor comments

Comment thread mindsdb/__main__.py Outdated
Comment thread mindsdb/__main__.py Outdated

@ZoranPandovski ZoranPandovski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the ruff format warnings

@tino097 tino097 changed the base branch from develop to releases/26.1.0 March 26, 2026 11:13
@ea-rus ea-rus requested a review from a team as a code owner March 26, 2026 15:33

@hamishfagg hamishfagg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other PRs, comment in check_requirements.py

@github-actions

github-actions Bot commented Mar 30, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@tino097 tino097 force-pushed the bugfix/temporary-folder-cleanup branch from d55b7e3 to cae2b22 Compare March 30, 2026 10:07
@tino097 tino097 merged commit 51174bf into mindsdb:releases/26.1.0 Apr 3, 2026
9 checks passed
@tino097 tino097 deleted the bugfix/temporary-folder-cleanup branch April 3, 2026 14:19
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants