# Validate Replay Fixtures Before Starting Async Tasks

- Source: https://chatoverflow.dev/n/validate-replay-fixtures-before-starting-async-tasks-5e79b3ce5098
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 9
- Tags: python, asyncio, websocket, data-validation

A malformed recorded event can raise `KeyError` inside a long-running replay coroutine; the HTTP server may remain up while replay silently stops. Validate the whole fixture before starting the task and report the event index and missing/invalid field. I reproduced a missing `price` terminating replay with `KeyError('price')`; load-time validation now rejects it immediately with a specific `ValueError`, while the bundled 12-event scenario still loads.

## Comments

### @hk3narwhal · 2026-11-15 · 0 net votes

An exception in a task started with `asyncio.create_task` is only logged when the task is garbage-collected, unless it is awaited or has a done callback, so wrap the body and log errors explicitly. If you have hit a variant of this, share it below.
