[Bot] A failure midway through converting raw tracks deletes the tracks not yet converted #520

Open
opened 2026-09-06 03:03:28 +00:00 by claude-bot · 0 comments
Contributor

Found while doing #393 (v4.3.0 phase 5), outside that lane's scope; same family as #399.

RecordingCog._process in bot/questboard_bot/cogs/recording.py converts each speaker's raw capture track ({session_id}_{user_id}_raw.16k-mono.s16le) into its WAV and, in a finally: block at the end, unlinks every remaining entry of raw_track_files. The normal stop path deletes each raw track as soon as it is converted, so on success the finally has nothing to do. But if the conversion loop raises partway (disk full, a corrupt track, an exception in the WAV writer), the finally still runs and deletes the raw tracks that were not converted, which is the only copy of that audio. The failure message the GM sees was reworded in #393 so it makes no promise about what is left on disk, but the loss itself still happens.

Expected: a failure in the conversion loop leaves the unconverted raw tracks in place, so #399's startup recovery (which treats leftover raw tracks as the signal that a recording never finished) can convert and hand them off on the next start, or an operator can. The cleanup should only remove tracks that have a WAV to show for them.

Acceptance:

  • A test that makes conversion fail on the second of three tracks asserts the third raw track still exists afterwards (and the first's WAV does).
  • The finally (or its replacement) removes only raw tracks whose WAV was written.
  • recover_interrupted_recordings picks the survivors up on the next start (existing behaviour; add a test if one does not cover this shape).
Found while doing #393 (v4.3.0 phase 5), outside that lane's scope; same family as #399. `RecordingCog._process` in `bot/questboard_bot/cogs/recording.py` converts each speaker's raw capture track (`{session_id}_{user_id}_raw.16k-mono.s16le`) into its WAV and, in a `finally:` block at the end, unlinks every remaining entry of `raw_track_files`. The normal stop path deletes each raw track as soon as it is converted, so on success the `finally` has nothing to do. But if the conversion loop raises partway (disk full, a corrupt track, an exception in the WAV writer), the `finally` still runs and deletes the raw tracks that were **not** converted, which is the only copy of that audio. The failure message the GM sees was reworded in #393 so it makes no promise about what is left on disk, but the loss itself still happens. Expected: a failure in the conversion loop leaves the unconverted raw tracks in place, so #399's startup recovery (which treats leftover raw tracks as the signal that a recording never finished) can convert and hand them off on the next start, or an operator can. The cleanup should only remove tracks that have a WAV to show for them. Acceptance: - [ ] A test that makes conversion fail on the second of three tracks asserts the third raw track still exists afterwards (and the first's WAV does). - [ ] The `finally` (or its replacement) removes only raw tracks whose WAV was written. - [ ] `recover_interrupted_recordings` picks the survivors up on the next start (existing behaviour; add a test if one does not cover this shape).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/Quest-Board#520
No description provided.