bug: GET /refractor/cards returns count: null with out-of-range tier filter #182
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#182
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
Description
GET /api/v2/refractor/cards?team_id=31&tier=99returns{"count": null, "items": []}instead of{"count": 0, "items": []}.Valid tier values are 0–4. When an out-of-range value is passed, the count field comes back as
nullrather than0. Theitemsarray is correctly empty.Steps to Reproduce
Actual:
{"count": null, "items": []}Expected:
{"count": 0, "items": []}or a 422 validation error rejecting tier values outside 0–4Impact
Low — cosmetic/contract issue. The bot handles empty responses gracefully, but API consumers relying on
countbeing an integer will getNone.Found during REF-API integration testing (2026-04-06).
Fixed in PR #184.
Root cause: Peewee 3.17.9's
.count()on a complex three-table JOIN (RefractorCardState → RefractorTrack → Player LEFT OUTER) can returnNonerather than0when the query matches zero rows.Fix:
total = query.count() or 0inapp/routers_v2/refractor.py— one-line defensive guard ensuringcountis always an integer.Note on the exact repro (
tier=99): Thetierparameter already hasge=0, le=4FastAPI validation, sotier=99now returns a 422 before the query runs. Theor 0guard covers all other zero-result scenarios (valid tier with no matching cards, etc.).