Skip to content

Fix: ensure temp file created during script instrumentation is always cleaned up#197

Merged
siddu-k merged 1 commit into
siddu-k:mainfrom
YUVRAJ-SINGH-3178:fix/tempfile-leak
Jun 4, 2026
Merged

Fix: ensure temp file created during script instrumentation is always cleaned up#197
siddu-k merged 1 commit into
siddu-k:mainfrom
YUVRAJ-SINGH-3178:fix/tempfile-leak

Conversation

@YUVRAJ-SINGH-3178
Copy link
Copy Markdown
Contributor

Summary: Fixes a temp-file leak when script instrumentation creates a temporary file but writing to it fails. The code now tracks the created temp path and always passes that path into cleanup so orphaned .tmp_run_*.sh files are removed on error/finally paths.

  • Problem: instrumentation uses tempfile.mkstemp() and assigns run_path = temp_path only on successful write; if the write fails the code falls back to full_path and the created temp file can be left on disk.
  • Change: track temp_path_created when a temp file is created and pass it to _cleanup_execution() (used on error paths and in finally) so the temp file is unlinked regardless of run_path reassignment.
  • Files changed: app.py (script run / instrumentation / cleanup)
  • Behavioral impact: no functional behavior change when instrumentation succeeds; prevents orphaned temp files on write failure.

How to test locally

  1. Start the backend.
  2. Trigger a scripted run that exercises instrumentation.
  3. Simulate a write failure (e.g., make the script directory unwritable or fill disk).
  4. Confirm no .tmp_run_*.sh files remain after the run or error path.

closes Issue #196

Copilot AI review requested due to automatic review settings June 2, 2026 03:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@siddu-k siddu-k merged commit acec171 into siddu-k:main Jun 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants