fix: auto-initialize RefractorCardState in evaluate-game #178
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#178
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/refractor-auto-init-missing-states"
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
RefractorCardStaterow. Previouslyevaluate-gamesilently skipped these players.initialize_card_refractoron-the-fly when a state is missing, so any card used in a game gets refractor tracking regardless of when it was created.Changes
app/routers_v2/refractor.py: Replaceif state is None: continuewith auto-init viainitialize_card_refractor(idempotent, failure-safe)initialize_card_refractorand_determine_card_typefromrefractor_initTest plan
evaluate-game— states should be auto-createdevaluate-gameon same game, no errors or duplicates🤖 Generated with Claude Code
AI Code Review
Files Reviewed
app/routers_v2/refractor.py(modified)app/services/refractor_init.py(read for context — unchanged)Findings
Correctness
continuewith an auto-init block is logically correct. Whenstate is None, the code fetches the player, determines card type, and callsinitialize_card_refractor— which is idempotent viaget_or_create.if state is None: continueguard after the except block correctly handles the case whereinitialize_card_refractorreturnsNone(missing track, DB error, etc.) — no NPE can proceed downstream.Player.get_by_idfailure is caught by the broadexcept Exception, leavingstate = None, which then triggerscontinue. Correct.state is None.Security
Style & Conventions
initialize_card_refractorand_determine_card_typeis correct — CLAUDE.md explicitly notes lazy imports should not be added to the middle of files. The_determine_card_typeunderscore prefix is intentional:refractor_init.py's module docstring explicitly lists it as exported for use by routers and tests.except Exception+logger.warning) matches the existing style throughoutevaluate_game.Suggestions
Verdict: APPROVED
Clean, targeted fix. The implementation is correct, idempotent, failure-safe, and follows existing conventions. Critical for season rollover — any card that appears in a game will now get a refractor state initialized on-the-fly rather than being silently skipped.
Automated review by Claude PR Reviewer
Approved via pd-pr