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

Closed
cal wants to merge 1 commits from ai/paper-dynasty-database-36 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 ruff linter hook reformatted the entire file (single → double quotes, line wrapping) on save. The functional diff is only the removal of the three roster columns.

Other Observations

  • v1_cards_patch 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.
## 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 ruff linter hook reformatted the entire file (single → double quotes, line wrapping) on save. The functional diff is only the removal of the three roster columns. ## Other Observations - `v1_cards_patch` 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.
cal added 1 commit 2026-03-03 19:36:48 +00:00
fix: remove dead roster fields from CSV in v1_cards_get_one (#36)
All checks were successful
Build Docker Image / build (pull_request) Successful in 50s
e46a6e7493
Removes non-existent roster1/roster2/roster3 columns from CSV output.
Accessing this_card.roster1.name raised AttributeError at runtime for
any GET /api/v2/cards/{card_id}?csv=true request.

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

AI Code Review

Files Reviewed

  • app/routers_v2/cards.py (modified)

Findings

Correctness

  • Fix is verified correct. The Card model in db_engine.py (lines 472–491) defines only player, team, pack, and value fields — no roster1, roster2, or roster3. The old code accessing this_card.roster1.name etc. would unconditionally raise AttributeError on any GET /api/v2/cards/{card_id}?csv=true request. Removal is the right fix.
  • The remaining CSV fields (id, player, team.abbrev, pack, value) all correspond to valid Card model fields.
  • Minor pre-existing inconsistency (out of scope): get_cards CSV uses line.player.p_name for the player name, but v1_cards_get_one CSV emits this_card.player (the model object, which renders as its __str__). This divergence predates this PR and should be addressed separately if consistency matters.

Security

  • No issues. The CSV path only reads a card by ID — lookup is already guarded with a 404 before the CSV branch is reached. No user input reaches the CSV data construction.

Style & Conventions

  • The ruff hook reformatted the entire file (single → double quotes, line wrapping) alongside the functional change. This creates a noisy diff but the reformatting itself is correct and consistent. The functional diff is cleanly isolated to the v1_cards_get_one CSV block.

Suggestions

  • As noted in the PR body, v1_cards_patch (lines 332–337 in the original file) still assigns this_card.roster1_id, roster2_id, roster3_id — undeclared Peewee fields that are silently dropped by save(). Worth a follow-up issue to remove those dead params from the API surface.

Verdict: APPROVED ✓

Clean, correct removal of dead code that was causing a guaranteed runtime crash. Model inspection confirms no roster fields exist. No security or convention issues introduced.

Note: Gitea does not allow self-approval; posting as COMMENT. This review recommends merging.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `app/routers_v2/cards.py` (modified) ### Findings #### Correctness - **Fix is verified correct.** The `Card` model in `db_engine.py` (lines 472–491) defines only `player`, `team`, `pack`, and `value` fields — no `roster1`, `roster2`, or `roster3`. The old code accessing `this_card.roster1.name` etc. would unconditionally raise `AttributeError` on any `GET /api/v2/cards/{card_id}?csv=true` request. Removal is the right fix. - The remaining CSV fields (`id`, `player`, `team.abbrev`, `pack`, `value`) all correspond to valid `Card` model fields. - Minor pre-existing inconsistency (out of scope): `get_cards` CSV uses `line.player.p_name` for the player name, but `v1_cards_get_one` CSV emits `this_card.player` (the model object, which renders as its `__str__`). This divergence predates this PR and should be addressed separately if consistency matters. #### Security - No issues. The CSV path only reads a card by ID — lookup is already guarded with a 404 before the CSV branch is reached. No user input reaches the CSV data construction. #### Style & Conventions - The ruff hook reformatted the entire file (single → double quotes, line wrapping) alongside the functional change. This creates a noisy diff but the reformatting itself is correct and consistent. The functional diff is cleanly isolated to the `v1_cards_get_one` CSV block. #### Suggestions - As noted in the PR body, `v1_cards_patch` (lines 332–337 in the original file) still assigns `this_card.roster1_id`, `roster2_id`, `roster3_id` — undeclared Peewee fields that are silently dropped by `save()`. Worth a follow-up issue to remove those dead params from the API surface. ### Verdict: APPROVED ✓ Clean, correct removal of dead code that was causing a guaranteed runtime crash. Model inspection confirms no roster fields exist. No security or convention issues introduced. > Note: Gitea does not allow self-approval; posting as COMMENT. This review recommends merging. --- *Automated review by Claude PR Reviewer*
cal added the
ai-reviewed
label 2026-03-03 20:03:59 +00:00
cal added the
ai-working
label 2026-03-03 20:35:10 +00:00
cal added
ai-pr-opened
and removed
ai-working
labels 2026-03-03 20:36:19 +00:00
Author
Owner

Fixed in PR #39: #39

Removed roster1, roster2, roster3 from the CSV header and data row in v1_cards_get_one. These fields don't exist on the Card model, so accessing them would raise AttributeError at runtime.

Fixed in PR #39: https://git.manticorum.com/cal/paper-dynasty-database/pulls/39 Removed `roster1`, `roster2`, `roster3` from the CSV header and data row in `v1_cards_get_one`. These fields don't exist on the `Card` model, so accessing them would raise `AttributeError` at runtime.
cal closed this pull request 2026-03-03 21:14:33 +00:00
All checks were successful
Build Docker Image / build (pull_request) Successful in 50s

Pull request closed

Sign in to join this conversation.
No description provided.