fix(api): raise 403 on scouting auth failure instead of returning 200 (#213) #214
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
autonomous
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
size:M
size:S
tech-debt
todo
type:feature
type:stability
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#214
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/213-fix-api-scouting-endpoints-return-200-on-auth-fail"
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?
Closes #213
Both
/scoutingendpoints werereturn-ing the auth failure message as a plain string with HTTP 200. Google Sheets clients see 200, try to parse the error text as CSV, and surface confusing downstream errors.Changes
app/routers_v2/battingcardratings.py:return (...)→raise HTTPException(status_code=403, detail=...)app/routers_v2/pitchingcardratings.py: same changeHTTPExceptionwas already imported in both files. Success path (CSVFileResponse) is unchanged.Other observations
battingcardratings.py:332:logging.debug(f"Team: {this_team} / has_guide: {this_team.has_guide}")runs before thethis_team is Noneguard — will raiseAttributeErrorif team is not found. Pre-existing bug, out of scope.AI Code Review
Files Reviewed
app/routers_v2/battingcardratings.py(modified)app/routers_v2/pitchingcardratings.py(modified)Findings
Correctness
No issues found.
HTTPExceptionwas already imported at line 3 in both files — no import changes needed. ✅status_code=403is correct for "forbidden" (team lacks guide access). ✅detail=string is identical to the former plain-string return — no content change. ✅FileResponsereturning CSV) is untouched. ✅Security
No issues found. 403 is the appropriate HTTP status for access control failure. No credentials or sensitive data introduced.
Style & Conventions
No issues found.
raise HTTPException(...)is the existing FastAPI idiom used throughout both files for other auth failures (e.g.,POST /calculate/scoutingat line 357/277).Suggestions
logging.debug(f"Team: {this_team} / has_guide: {this_team.has_guide}")at line 332 (batting) / 252 (pitching) runs before theif this_team is Noneguard and will raiseAttributeErroron a missing team. The PR author correctly identified this as out of scope. Worth a follow-up issue.Verdict: COMMENT
Self-review restriction — no blocking issues. Code is correct and ready to merge.
Automated review by Claude PR Reviewer