fix: compute CSV after appending data row in get_one_player (#12) #51
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
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#51
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-database-12"
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
Fixes
get_one_playerCSV 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 todata_liston 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 afterdata_list.append(...)so the DataFrame includes both the header and the player data row.Files Changed
app/routers_v2/players.py— swapped order ofto_csv()call anddata_list.append()Test Results
No test suite — verified by reading the corrected code. The diff is a single-line move with no logic changes.
AI Code Review
Files Reviewed
app/routers_v2/players.py(modified)Findings
Correctness
data_listis initialized with only the header row ([[...22 column names...]]), so callingDataFrame(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. Movingto_csv()to afterdata_list.append(...)ensures both rows are present in the DataFrame before serialization.[header_row, data_row]) passed toDataFramewithheader=Falseproduces the correct output after the fix.Security
Style & Conventions
Suggestions
data_listand usingheader=Falseis a bit unconventional pandas usage (named columns withheader=Truewould 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
7a7935394cto0166c7dda4