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

Closed
cal wants to merge 1 commits from ai/paper-dynasty-database-37 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. raises 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 row

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 has 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. raises `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 row ## 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` has 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 20:36:11 +00:00
fix: remove dead roster fields from CSV in v1_cards_get_one (#37)
All checks were successful
Build Docker Image / build (pull_request) Successful in 3m13s
20cfcff9f9
Accessing this_card.roster1.name etc. raises AttributeError at runtime
since the Card model has no roster fields. Removed roster1/2/3 from
both the CSV header and data row.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cal added the
ai-reviewing
label 2026-03-03 20:46:33 +00:00
cal reviewed 2026-03-03 20:48:56 +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. Confirmed against db_engine.py: the Card model (line 472) declares only player, team, pack, and value as fields — no roster1, roster2, or roster3. The old this_card.roster1.name access was a guaranteed 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 fields on the Card model.
  • Note: this_card.player serializes as the Peewee model repr in CSV (e.g. <Player: 42>), not the player name. This is pre-existing behavior not introduced by this PR and is consistent with the same pattern in the non-CSV path.

Security

  • No issues. Auth is enforced consistently across all write endpoints.

Style & Conventions

  • The ruff reformatter converted single → double quotes and applied line-wrapping throughout the file. This is cosmetic, consistent, and expected given the project's linting hook. It does not affect functionality.

Suggestions

  • The PR correctly calls out v1_cards_patch (lines 332–337 of current main) still accepting roster1_id, roster2_id, roster3_id query parameters that silently no-op (Peewee ignores assignments to undeclared fields on save()). This is dead API surface but not a crash risk. Recommend tracking this as a follow-up issue.

Verdict: APPROVED

The functional fix is minimal, correct, and addresses a runtime crash. The ruff reformatting is noise but harmless. Safe to merge.


Automated review by Claude PR Reviewer (COMMENT posted — Gitea does not permit self-approval)

## AI Code Review ### Files Reviewed - `app/routers_v2/cards.py` (modified) ### Findings #### Correctness - **Fix is verified correct.** Confirmed against `db_engine.py`: the `Card` model (line 472) declares only `player`, `team`, `pack`, and `value` as fields — no `roster1`, `roster2`, or `roster3`. The old `this_card.roster1.name` access was a guaranteed `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 fields on the `Card` model. - Note: `this_card.player` serializes as the Peewee model repr in CSV (e.g. `<Player: 42>`), not the player name. This is pre-existing behavior not introduced by this PR and is consistent with the same pattern in the non-CSV path. #### Security - No issues. Auth is enforced consistently across all write endpoints. #### Style & Conventions - The ruff reformatter converted single → double quotes and applied line-wrapping throughout the file. This is cosmetic, consistent, and expected given the project's linting hook. It does not affect functionality. #### Suggestions - The PR correctly calls out `v1_cards_patch` (lines 332–337 of current `main`) still accepting `roster1_id`, `roster2_id`, `roster3_id` query parameters that silently no-op (Peewee ignores assignments to undeclared fields on `save()`). This is dead API surface but not a crash risk. Recommend tracking this as a follow-up issue. ### Verdict: APPROVED The functional fix is minimal, correct, and addresses a runtime crash. The ruff reformatting is noise but harmless. Safe to merge. --- *Automated review by Claude PR Reviewer (COMMENT posted — Gitea does not permit self-approval)*
cal added
ai-reviewed
and removed
ai-reviewing
labels 2026-03-03 20:49:25 +00:00
cal closed this pull request 2026-03-03 21:14:34 +00:00
All checks were successful
Build Docker Image / build (pull_request) Successful in 3m13s

Pull request closed

Sign in to join this conversation.
No description provided.