- Summary: Instrumentation creates a temp file via
tempfile.mkstemp() and sets run_path to it after a successful write. If the write fails, the code falls back to the original full_path but the created temp file can be left orphaned on disk.
- Location: app.py (script instrumentation / run path handling).
- Steps to reproduce:
- Trigger a script run that causes instrumentation (the
/api/scripts/run flow).
- Simulate a write failure (e.g., make the script directory unwritable or fill the disk).
- Observe a
.tmp_run_*.sh temp file remains after the error.
- Expected: Any temp file created during instrumentation is always removed, even if writing fails.
- Actual: Created temp file can persist when the write fails and
run_path is reset to full_path.
- Suggested fix: Track the created temp path separately (e.g.,
temp_path_created) and always attempt to unlink it in cleanup/finally (or use NamedTemporaryFile(delete=True) / context manager).
@siddu-k Assign me this issue
tempfile.mkstemp()and setsrun_pathto it after a successful write. If the write fails, the code falls back to the originalfull_pathbut the created temp file can be left orphaned on disk./api/scripts/runflow)..tmp_run_*.shtemp file remains after the error.run_pathis reset tofull_path.temp_path_created) and always attempt to unlink it in cleanup/finally (or useNamedTemporaryFile(delete=True)/ context manager).@siddu-k Assign me this issue