fix: surface nba api http response errors#679
Open
vikramdurai wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #678.
This updates the shared HTTP layer so NBA API response failures are surfaced before JSON parsing turns them into misleading
JSONDecodeErrors. It also adds the live CDNRefererheader needed for currentnba_api.liverequests.This includes the live header fix from #671, then extends the error handling beyond the narrower approaches in #659 and #657: HTTP status is checked before parsing, structured response context is preserved, partial-content responses are rejected, and JSON decode failures include useful response metadata. #675 touches session/test isolation but does not address the HTTP status / non-JSON response handling in #678.
Changes
NBAError,NBAHTTPError,NBARequestError, andNBAJSONDecodeErrorNBAHTTPErrorfor non-2xx responses before parsing response bodiesNBAHTTPErrorfor206 Partial ContentNBAJSONDecodeErrorwith status, URL, content type, body preview, and reason hintNBARequestErrorReferer: https://www.nba.com/to live endpoint default headersVerification
Result:
528 passed, 1 warningAlso manually verified live behavior:
ScoreBoard()succeeds with default headersRefererraisesNBAHTTPErrorwith403 text/html access_deniedinstead of surfacing as a JSON parse failure