fix: add type annotations to untyped query parameters (#73) #86

Open
Claude wants to merge 1 commits from issue/73-add-type-annotations-to-untyped-query-parameters into main
Collaborator

Closes #73

Summary

Added missing int type annotations to two endpoint parameters that FastAPI was treating as strings:

  • season: int in app/routers_v3/transactions.py (GET /api/v3/transactions)
  • stan_id: int in app/routers_v3/standings.py (PATCH /api/v3/standings/{stan_id})

Without annotations, FastAPI passes these as strings to the ORM, which can cause type mismatches when PostgreSQL compares them against integer columns.

Files Changed

  • app/routers_v3/transactions.pyseason parameter annotated as int
  • app/routers_v3/standings.pystan_id path parameter annotated as int

Tests

No test suite configured for this repo. Changes verified by reading back modified files.

Closes #73 ## Summary Added missing `int` type annotations to two endpoint parameters that FastAPI was treating as strings: - `season: int` in `app/routers_v3/transactions.py` (`GET /api/v3/transactions`) - `stan_id: int` in `app/routers_v3/standings.py` (`PATCH /api/v3/standings/{stan_id}`) Without annotations, FastAPI passes these as strings to the ORM, which can cause type mismatches when PostgreSQL compares them against integer columns. ## Files Changed - `app/routers_v3/transactions.py` — `season` parameter annotated as `int` - `app/routers_v3/standings.py` — `stan_id` path parameter annotated as `int` ## Tests No test suite configured for this repo. Changes verified by reading back modified files.
Claude added 1 commit 2026-03-27 05:03:11 +00:00
fix: add type annotations to untyped query parameters (#73)
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m11s
dcaf184ad3
Closes #73

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-03-27 05:15:52 +00:00
Claude reviewed 2026-03-27 05:16:44 +00:00
Claude left a comment
Author
Collaborator

AI Code Review

Files Reviewed

  • app/routers_v3/transactions.py (modified)
  • app/routers_v3/standings.py (modified)

Findings

Correctness

  • standings.py: stan_id: int on a path parameter (/{stan_id}) is correct. FastAPI will now validate and coerce the path segment to int before passing to Standings.get_by_id(stan_id), eliminating the ORM string/int mismatch.
  • transactions.py: season: int on a query parameter is correct. The parameter has no default so it remains required; FastAPI now also validates the value is a valid integer (returns 422 on bad input instead of passing a string to Transaction.select_season).
  • Both changes are minimal and exactly match their intent.

Security

  • No issues introduced. No new injection surfaces, no credentials exposed.

Style & Conventions

  • Follows the existing pattern in both files: get_standings already uses season: int, get_team_standings uses team_id: int, post_standings uses season: int. These two annotations bring the remaining untyped params in line.
  • No unnecessary imports added.

Suggestions

  • (Pre-existing, out of scope) patch_transactions and delete_transactions in transactions.py still have untyped move_id path params. Worth a follow-up issue.
  • (Pre-existing, out of scope) logger.warning(f"patch_standings - Bad Token: {token}") still interpolates the token value — tracked separately.

Verdict: APPROVED

Both changes are correct, minimal, and consistent with the existing annotation patterns in each file. FastAPI's automatic coercion and 422 validation on these parameters is strictly better than the previous untyped behavior.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `app/routers_v3/transactions.py` (modified) - `app/routers_v3/standings.py` (modified) ### Findings #### Correctness - `standings.py`: `stan_id: int` on a path parameter (`/{stan_id}`) is correct. FastAPI will now validate and coerce the path segment to int before passing to `Standings.get_by_id(stan_id)`, eliminating the ORM string/int mismatch. - `transactions.py`: `season: int` on a query parameter is correct. The parameter has no default so it remains required; FastAPI now also validates the value is a valid integer (returns 422 on bad input instead of passing a string to `Transaction.select_season`). - Both changes are minimal and exactly match their intent. #### Security - No issues introduced. No new injection surfaces, no credentials exposed. #### Style & Conventions - Follows the existing pattern in both files: `get_standings` already uses `season: int`, `get_team_standings` uses `team_id: int`, `post_standings` uses `season: int`. These two annotations bring the remaining untyped params in line. - No unnecessary imports added. #### Suggestions - (Pre-existing, out of scope) `patch_transactions` and `delete_transactions` in `transactions.py` still have untyped `move_id` path params. Worth a follow-up issue. - (Pre-existing, out of scope) `logger.warning(f"patch_standings - Bad Token: {token}")` still interpolates the token value — tracked separately. ### Verdict: APPROVED Both changes are correct, minimal, and consistent with the existing annotation patterns in each file. FastAPI's automatic coercion and 422 validation on these parameters is strictly better than the previous untyped behavior. --- *Automated review by Claude PR Reviewer*
Claude added the
ai-reviewed
label 2026-03-27 05:17:11 +00:00
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m11s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue/73-add-type-annotations-to-untyped-query-parameters:issue/73-add-type-annotations-to-untyped-query-parameters
git checkout issue/73-add-type-annotations-to-untyped-query-parameters
Sign in to join this conversation.
No reviewers
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/major-domo-database#86
No description provided.