fix: compute CSV after appending data row in get_one_player (#12) #51

Merged
cal merged 1 commits from ai/paper-dynasty-database-12 into next-release 2026-03-05 03:32:22 +00:00
Owner

Summary

Fixes get_one_player CSV response always returning only the header row.

Root cause: return_val = DataFrame(data_list).to_csv(...) was called on line 625 before the player data row was appended to data_list on line 626. The CSV was computed from a list containing only the header, so the data row was never included in the response.

Fix: Moved to_csv() call to after data_list.append(...) so the DataFrame includes both the header and the player data row.

Files Changed

  • app/routers_v2/players.py — swapped order of to_csv() call and data_list.append()

Test Results

No test suite — verified by reading the corrected code. The diff is a single-line move with no logic changes.

## Summary Fixes `get_one_player` CSV response always returning only the header row. **Root cause:** `return_val = DataFrame(data_list).to_csv(...)` was called on line 625 before the player data row was appended to `data_list` on line 626. The CSV was computed from a list containing only the header, so the data row was never included in the response. **Fix:** Moved `to_csv()` call to after `data_list.append(...)` so the DataFrame includes both the header and the player data row. ## Files Changed - `app/routers_v2/players.py` — swapped order of `to_csv()` call and `data_list.append()` ## Test Results No test suite — verified by reading the corrected code. The diff is a single-line move with no logic changes.
cal added 1 commit 2026-03-04 02:31:56 +00:00
return_val was assigned from DataFrame(data_list).to_csv() before the
player data row was appended to data_list, so the CSV response contained
only the header row. Moved the to_csv() call to after the append.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cal added the
ai-reviewing
label 2026-03-04 02:46:54 +00:00
cal reviewed 2026-03-04 02:48:30 +00:00
cal left a comment
Author
Owner

AI Code Review

Files Reviewed

  • app/routers_v2/players.py (modified)

Findings

Correctness

  • The root cause is accurately identified and the fix is correct. data_list is initialized with only the header row ([[...22 column names...]]), so calling DataFrame(data_list).to_csv(header=False, index=False) before the append produced a single-row CSV with just the column names — the player data was never included. Moving to_csv() to after data_list.append(...) ensures both rows are present in the DataFrame before serialization.
  • The two-element list structure ([header_row, data_row]) passed to DataFrame with header=False produces the correct output after the fix.

Security

  • No issues found. No user input flows into the CSV construction.

Style & Conventions

  • No issues found. The change is a minimal line reorder with no new logic, matching the existing code style.

Suggestions

  • The pattern of building the header as the first element of data_list and using header=False is a bit unconventional pandas usage (named columns with header=True would be more idiomatic), but this is a pre-existing style issue outside the scope of this PR.

Verdict: APPROVED

Minimal, correct, surgical fix for a clear ordering bug. The PR description accurately describes both the root cause and the fix. No concerns.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `app/routers_v2/players.py` (modified) ### Findings #### Correctness - The root cause is accurately identified and the fix is correct. `data_list` is initialized with only the header row (`[[...22 column names...]]`), so calling `DataFrame(data_list).to_csv(header=False, index=False)` before the append produced a single-row CSV with just the column names — the player data was never included. Moving `to_csv()` to after `data_list.append(...)` ensures both rows are present in the DataFrame before serialization. - The two-element list structure (`[header_row, data_row]`) passed to `DataFrame` with `header=False` produces the correct output after the fix. #### Security - No issues found. No user input flows into the CSV construction. #### Style & Conventions - No issues found. The change is a minimal line reorder with no new logic, matching the existing code style. #### Suggestions - The pattern of building the header as the first element of `data_list` and using `header=False` is a bit unconventional pandas usage (named columns with `header=True` would be more idiomatic), but this is a pre-existing style issue outside the scope of this PR. ### Verdict: APPROVED Minimal, correct, surgical fix for a clear ordering bug. The PR description accurately describes both the root cause and the fix. No concerns. --- *Automated review by Claude PR Reviewer*
cal added the
ai-reviewed
label 2026-03-04 02:48:59 +00:00
cal force-pushed ai/paper-dynasty-database-12 from 7a7935394c to 0166c7dda4 2026-03-05 03:32:11 +00:00 Compare
cal merged commit 110493d1b0 into next-release 2026-03-05 03:32:22 +00:00
cal deleted branch ai/paper-dynasty-database-12 2026-03-05 03:32:22 +00:00
Sign in to join this conversation.
No description provided.