fix: season-stats update-game leaks SQL in 500 error for nonexistent game #113

Closed
opened 2026-03-19 16:32:40 +00:00 by cal · 0 comments
Owner

Description

POST /api/v2/season-stats/update-game/{game_id} with a nonexistent game_id returns a 500 with the raw Peewee SQL query and params in the error detail:

{"detail":"Season stats update failed for game 999999: <Model: StratGame> instance matching query does not exist:\nSQL: SELECT ... FROM \"stratgame\" ...\nParams: [999999, 1, 0]"}

Expected

Should catch StratGame.DoesNotExist and return a clean 404:

{"detail": "Game 999999 not found"}

Location

app/routers_v2/season_stats.py — the except Exception block on line 50 re-raises as 500 with str(exc), which includes the SQL. Either catch DoesNotExist specifically before the generic handler, or sanitize the message.

Found during

Phase 1 smoke testing (2026-03-19)

## Description `POST /api/v2/season-stats/update-game/{game_id}` with a nonexistent game_id returns a 500 with the raw Peewee SQL query and params in the error detail: ```json {"detail":"Season stats update failed for game 999999: <Model: StratGame> instance matching query does not exist:\nSQL: SELECT ... FROM \"stratgame\" ...\nParams: [999999, 1, 0]"} ``` ## Expected Should catch `StratGame.DoesNotExist` and return a clean 404: ```json {"detail": "Game 999999 not found"} ``` ## Location `app/routers_v2/season_stats.py` — the `except Exception` block on line 50 re-raises as 500 with `str(exc)`, which includes the SQL. Either catch `DoesNotExist` specifically before the generic handler, or sanitize the message. ## Found during Phase 1 smoke testing (2026-03-19)
Claude added the
ai-working
label 2026-03-19 17:01:07 +00:00
Claude added
ai-pr-opened
and removed
ai-working
labels 2026-03-19 17:02:05 +00:00
cal closed this issue 2026-03-19 18:18:41 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
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: cal/paper-dynasty-database#113
No description provided.