Files
agentic_security/agentic_security
jiawenlai1109 1fd08f50ee fix(audio_generator): clean up temp file when gTTS save() fails
generate_audio_cross_platform() created the temp MP3 via tts.save() one
statement *before* the try/finally that was supposed to remove it, so any
exception raised by the save itself escaped the cleanup and left
temp_audio_<hex>.mp3 in the current working directory.

gTTS.save() performs an outbound HTTP request, which is exactly the path that
fails offline or behind egress restrictions, and .gitignore does not cover the
temp_audio_* pattern - so every such run litters the working tree.

Move the save inside the existing try. Success-path behaviour is unchanged, and
this now matches how generate_audio_mac_wav() in the same file already guards
its two temp paths.

Verified on Ubuntu 22.04 / Python 3.14.7, same offline-failing test before and
after: leaked temp_audio_*.mp3 count went 1 -> 0, test result unchanged
(1 failed, gTTSError: Failed to connect). black --check passes; rest of the
module is 1 passed, 1 skipped, 1 pre-existing offline failure.
2026-09-22 17:55:01 +08:00
..
2026-05-14 19:08:40 +03:00
2025-11-30 18:50:00 +02:00
2026-09-07 14:03:57 +03:00
2026-09-07 14:03:57 +03:00
2026-09-07 14:03:57 +03:00
2025-12-24 08:16:21 +02:00
2025-02-20 16:05:34 +02:00
2025-02-21 19:17:45 +02:00
2026-09-07 14:03:57 +03:00
2026-06-03 14:59:43 +03:00