fix: guard db_game against NameError when db_post fails in complete_game (#27)
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m24s
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m24s
Initialize db_game = None before try block and guard roll_back call
with `if db_game is not None:` to prevent NameError masking the
original exception when db_post("games") raises before assignment.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ce894cfa64
commit
678fa320df
@ -4295,12 +4295,14 @@ async def complete_game(
|
||||
else this_game.away_team
|
||||
)
|
||||
|
||||
db_game = None
|
||||
try:
|
||||
db_game = await db_post("games", payload=game_data)
|
||||
db_ready_plays = get_db_ready_plays(session, this_game, db_game["id"])
|
||||
db_ready_decisions = get_db_ready_decisions(session, this_game, db_game["id"])
|
||||
except Exception as e:
|
||||
await roll_back(db_game["id"])
|
||||
if db_game is not None:
|
||||
await roll_back(db_game["id"])
|
||||
log_exception(e, msg="Unable to post game to API, rolling back")
|
||||
|
||||
# Post game stats to API
|
||||
|
||||
Loading…
Reference in New Issue
Block a user