fix: remove dead roster fields from CSV in v1_cards_get_one (#35) #36

Closed
cal wants to merge 1 commits from ai/paper-dynasty-database#35 into main
Owner

Summary

Removes non-existent roster1, roster2, roster3 columns from the CSV output in v1_cards_get_one. Accessing this_card.roster1.name etc. would raise AttributeError at runtime for any GET /api/v2/cards/{card_id}?csv=true request.

Files Changed

  • app/routers_v2/cards.py — removed roster1, roster2, roster3 from CSV header and data rows

Fix

Before:

data_list = [
    ['id', 'player', 'team', 'pack', 'value', 'roster1', 'roster2', 'roster3'],
    [this_card.id, this_card.player, this_card.team.abbrev, this_card.pack, this_card.value,
     this_card.roster1.name, this_card.roster2.name, this_card.roster3.name]
]

After:

data_list = [
    ['id', 'player', 'team', 'pack', 'value'],
    [this_card.id, this_card.player, this_card.team.abbrev, this_card.pack, this_card.value]
]

Test Results

No test suite. Fix verified by code inspection — Card model in db_engine.py confirms fields are player, team, pack, value only (no roster fields).

Notes

  • The project linter hook (ruff) reformatted the file automatically when the edit was saved (single → double quotes, line wrapping). The functional diff is the removal of the three roster columns.
  • The v1_cards_patch endpoint still accepts roster1_id, roster2_id, roster3_id query parameters that are silently ignored (no assignment to this_card). This is dead API surface worth cleaning up separately — tracked in the issue body under "Other Observations".
## Summary Removes non-existent `roster1`, `roster2`, `roster3` columns from the CSV output in `v1_cards_get_one`. Accessing `this_card.roster1.name` etc. would raise `AttributeError` at runtime for any `GET /api/v2/cards/{card_id}?csv=true` request. ## Files Changed - `app/routers_v2/cards.py` — removed `roster1`, `roster2`, `roster3` from CSV header and data rows ## Fix **Before:** ```python data_list = [ ['id', 'player', 'team', 'pack', 'value', 'roster1', 'roster2', 'roster3'], [this_card.id, this_card.player, this_card.team.abbrev, this_card.pack, this_card.value, this_card.roster1.name, this_card.roster2.name, this_card.roster3.name] ] ``` **After:** ```python data_list = [ ['id', 'player', 'team', 'pack', 'value'], [this_card.id, this_card.player, this_card.team.abbrev, this_card.pack, this_card.value] ] ``` ## Test Results No test suite. Fix verified by code inspection — `Card` model in `db_engine.py` confirms fields are `player`, `team`, `pack`, `value` only (no roster fields). ## Notes - The project linter hook (ruff) reformatted the file automatically when the edit was saved (single → double quotes, line wrapping). The functional diff is the removal of the three roster columns. - The `v1_cards_patch` endpoint still accepts `roster1_id`, `roster2_id`, `roster3_id` query parameters that are silently ignored (no assignment to `this_card`). This is dead API surface worth cleaning up separately — tracked in the issue body under "Other Observations".
cal added 1 commit 2026-03-03 19:05:52 +00:00
fix: remove dead roster fields from CSV in v1_cards_get_one (#35)
All checks were successful
Build Docker Image / build (pull_request) Successful in 3m11s
50779d7027
Removed non-existent roster1, roster2, roster3 columns from both the
CSV header row and data row in the v1_cards_get_one endpoint. Accessing
these fields would raise AttributeError at runtime for any request with
?csv=true.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cal reviewed 2026-03-03 19:33:09 +00:00
cal left a comment
Author
Owner

AI Code Review

Files Reviewed

  • app/routers_v2/cards.py (modified)

Findings

Correctness

  • Fix is correct. Card model in db_engine.py (line 472) defines only player, team, pack, and value fields — no roster1/2/3 fields exist. The removed code would have raised AttributeError on every GET /api/v2/cards/{card_id}?csv=true request.
  • The remaining CSV columns (id, player, team.abbrev, pack, value) are all valid Card model attributes.

Security

  • No issues found.

Style & Conventions

  • The bulk ruff reformatting (single → double quotes, parameter list wrapping) is cosmetic and consistent throughout the file. No concerns.

Suggestions

  • this_card.player in the v1_cards_get_one CSV row serializes as the Player ORM object's __str__ representation, while the bulk get_cards CSV endpoint uses line.player.p_name. This inconsistency predates this PR and is out of scope, but worth aligning in a follow-up.
  • The v1_cards_patch endpoint (lines 332–337 in the pre-PR file) assigns this_card.roster1_id = roster1_id etc. Peewee silently ignores non-field attribute assignments during save(), so this is harmless but dead. The PR author correctly flags this for a separate cleanup issue.

Verdict: APPROVED

The fix precisely targets the runtime AttributeError in the CSV path of v1_cards_get_one. Model verification confirms the removed fields never existed on Card. The ruff reformatting is expected and non-functional. The two pre-existing issues noted are out of scope and appropriately deferred.

ℹ️ Gitea prevented a formal APPROVED vote (self-review restriction). Verdict is APPROVED — safe to merge.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `app/routers_v2/cards.py` (modified) ### Findings #### Correctness - Fix is correct. `Card` model in `db_engine.py` (line 472) defines only `player`, `team`, `pack`, and `value` fields — no `roster1/2/3` fields exist. The removed code would have raised `AttributeError` on every `GET /api/v2/cards/{card_id}?csv=true` request. - The remaining CSV columns (`id`, `player`, `team.abbrev`, `pack`, `value`) are all valid Card model attributes. #### Security - No issues found. #### Style & Conventions - The bulk ruff reformatting (single → double quotes, parameter list wrapping) is cosmetic and consistent throughout the file. No concerns. #### Suggestions - `this_card.player` in the `v1_cards_get_one` CSV row serializes as the Player ORM object's `__str__` representation, while the bulk `get_cards` CSV endpoint uses `line.player.p_name`. This inconsistency predates this PR and is out of scope, but worth aligning in a follow-up. - The `v1_cards_patch` endpoint (lines 332–337 in the pre-PR file) assigns `this_card.roster1_id = roster1_id` etc. Peewee silently ignores non-field attribute assignments during `save()`, so this is harmless but dead. The PR author correctly flags this for a separate cleanup issue. ### Verdict: APPROVED The fix precisely targets the runtime `AttributeError` in the CSV path of `v1_cards_get_one`. Model verification confirms the removed fields never existed on `Card`. The ruff reformatting is expected and non-functional. The two pre-existing issues noted are out of scope and appropriately deferred. > ℹ️ Gitea prevented a formal APPROVED vote (self-review restriction). Verdict is APPROVED — safe to merge. --- *Automated review by Claude PR Reviewer*
cal added the
ai-reviewed
label 2026-03-03 19:33:31 +00:00
cal added the
ai-working
label 2026-03-03 19:35:47 +00:00
cal removed the
ai-working
label 2026-03-03 19:37:17 +00:00
Author
Owner

Fixed in PR #37. Removed the non-existent roster1, roster2, roster3 columns from the CSV header and data row in v1_cards_get_one — these fields don't exist on the Card model and would raise AttributeError at runtime.

Fixed in PR #37. Removed the non-existent `roster1`, `roster2`, `roster3` columns from the CSV header and data row in `v1_cards_get_one` — these fields don't exist on the `Card` model and would raise `AttributeError` at runtime.
cal added the
ai-pr-opened
label 2026-03-03 19:37:28 +00:00
cal closed this pull request 2026-03-03 21:14:32 +00:00
All checks were successful
Build Docker Image / build (pull_request) Successful in 3m11s

Pull request closed

Sign in to join this conversation.
No description provided.