fix: add type annotations to untyped path parameters (#27) #43
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#43
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-database#27"
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
Adds
inttype annotations to four untyped path parameters so FastAPI can validate them and return 422 on bad input instead of unhandled DB errors.Changed functions:
players.py:590—get_one_player(player_id: int, ...)players.py:1122—delete_player(player_id: int, ...)packs.py:112—get_one_pack(pack_id: int, ...)teams.py:179—get_one_team(team_id: int, ...)What was fixed
Without type hints FastAPI treats path params as
str, skipping numeric validation. Non-integer inputs (e.g./api/v2/players/abc) would reach the ORM and raise an unhandled exception instead of a clean 422 response.Files changed
app/routers_v2/players.pyapp/routers_v2/packs.pyapp/routers_v2/teams.pyTests
No test suite exists in this repo. Changes verified by reading back modified function signatures.
🤖 Generated with Claude Code
AI Code Review
Files Reviewed
app/routers_v2/packs.py(modified)app/routers_v2/players.py(modified)app/routers_v2/teams.py(modified)Findings
Correctness
: intto path parameters (pack_id,player_id,team_id) causes FastAPI to coerce and validate the value before the handler is invoked, returning a clean 422 Unprocessable Entity for non-integer inputs rather than passing a string toget_by_id()and letting the ORM raise an unhandled exception.try/except Exception → HTTPException(404)guard beneath the signature change — the annotation does not break or bypass that logic.Security
intcoercion prevents non-numeric values from ever reaching the ORM query layer, reducing the attack surface for malformed path parameters.Style & Conventions
Suggestions
routers_v2/(e.g. ingauntlets.py,scouting.py). Worth a follow-up sweep if issue #27 didn't enumerate all of them.Verdict: APPROVED
Clean, correct, focused fix. All four annotations match the PR description exactly, follow FastAPI conventions, and improve input validation with no side effects.
Automated review by Claude PR Reviewer
8f3f4d1d58to5f86c8cb20