When handling errors, ensure you don’t (1) mask the original failure, (2) violate the intended timeout/retry/cleanup boundaries, or (3) make recovery decisions without explicit evidence.
Standards 1) Cleanup must never throw / must not mask the real exception
finally (e.g., worker/thread handles) or guard with getattr. class Runner:
def __init__(self):
self._tts_playback_thread = None # initialize for finally safety
def run(self):
try:
...
finally:
t = getattr(self, "_tts_playback_thread", None)
if t and t.is_alive():
t.join(timeout=5)
2) Honor deadlines everywhere (especially after streaming/pipes hit EOF)
3) Cleanup must cover the full resource scope
4) Recovery decisions must be evidence-gated
except Exception that collapses unrelated failures into the same recovery.5) Error ordering: validate ‘not found’ before operations that can raise 400/validation/unknown-task errors
6) Preserve best-effort behavior where it was intentional
Applying this standard will prevent masked exceptions, unblock deterministic cleanup/timeout behavior, and keep recovery logic correct and testable.
Enter the URL of a public GitHub repository