fix: season-stats update-game returns 404 for nonexistent game_id #117
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#117
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-database#113"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
DoesNotExistbefore the genericExceptionhandler inupdate_game_season_stats404 {"detail": "Game {game_id} not found"}instead of leaking raw Peewee SQL in a 500Closes #113
Test plan
POST /api/v2/season-stats/update-game/999999→404 {"detail": "Game 999999 not found"}POST /api/v2/season-stats/update-game/{valid_id}→200with updated counts (existing behaviour unchanged)🤖 Generated with Claude Code
AI Code Review
Files Reviewed
app/routers_v2/season_stats.py(modified)Findings
Correctness
StratGame.get_by_id(game_id)raisesStratGame.DoesNotExist(a Peewee model-specific subclass of the basepeewee.DoesNotExist). The newexcept DoesNotExistcatch uses the base class, which catches all model-specificDoesNotExistsubclasses — this works correctly.DoesNotExisthandler is placed before the genericexcept Exceptionblock, so it takes precedence as intended.from ..db_engine import DoesNotExistworks becausedb_engine.pyusesfrom peewee import *, pullingDoesNotExistinto its namespace. This is the exact same pattern used incurrent.py,cards.py,teams.py, and dozens of other routers throughout the codebase.from ..services.season_stats import update_season_stats, following the same lazy-import pattern already present in this function.Security
game_idis a typedintpath parameter — no injection risk in thedetail=f"Game {game_id} not found"string.Style & Conventions
DoesNotExisthandling (specific exception before generic 500 fallback).Suggestions
DoesNotExistis returned as a 404 without logging and shouldn't be retried. A one-line docstring update to mention the 404 case would improve accuracy. Non-blocking.Verdict: APPROVED
Clean, minimal fix. The exception hierarchy is correct, the import follows project conventions, and no security issues are introduced.
Automated review by Claude PR Reviewer (posted as COMMENT due to Gitea self-review restriction)