Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
When a 200 response body was not valid JSON, BaseClient._get logged the decode error and returned [], and _paginate_iter did the same. A get_* call returned [] instead of a model, and a list_* call yielded nothing if the first page was bad, or stopped early, without error, if a later page was bad. Callers silently got missing data. _decode now raises BadResponse with the response status and the first 200 bytes of the body, and _get and _paginate_iter let it propagate.
chipkent
force-pushed
the
fix/bad-json-response
branch
from
October 26, 2026 00:44
7aa587f to
13e57d4
Compare
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.
Fixes #<issue: F5c>
Builds on #12 (
BadResponse.status).When a 200 response body is not valid JSON (for example an HTML page from a proxy, or a truncated body),
BaseClient._getand_paginate_iterlog the decode error and return[]. Aget_*call returns[]instead of a model, and alist_*call yields nothing if the first page is bad, or stops early if a later page is bad. Either way the caller gets missing data with no error._decodenow raisesBadResponsewithstatus=resp.statusand the first 200 bytes of the body; thejsonerror is chained as__cause__._getand_paginate_iterdrop theirtry/exceptand let it propagate. These are the only two places that decode a response.BadResponsedocstring now covers this case.Valid responses are unaffected. A call that used to return
[]for a body it could not decode now raisesBadResponse, the exception callers already handle for non-200 responses.Tests in
test_rest/test_bad_response.pyuse pook to serve a non-JSON body to aget_*call, to the first page of alist_*call, and to its second page. All three fail without the fix.