call .raise_for_status() before .json() for certain requests - #15236
Open
talflon wants to merge 1 commit into
Open
call .raise_for_status() before .json() for certain requests#15236talflon wants to merge 1 commit into
talflon wants to merge 1 commit into
Conversation
- mostly for Metasmoke requests, because those often return empty responses - only where we depend on a successful JSON response - addresses Charcoal-SE#15227
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.
Addresses #15227.
.json()on Metasmoke requests was causing an error likeso this calls
raise_for_status()first, which will raise anHTTPErrorinstead if it's a 4xx or 5xx HTTP error.I also did this in
chatcommands.pull(), because that method appears to assume a successful response.I didn't do this for:
chatcommunicate.sendmessages(): seems there is some error handling in ChatExchangefindspam.toxic_check(): looks as if errors are returned as JSONMetasmoke.get()itself:MetasmokeCache.fetch_from_api()calls.get()and then handles the status code separatelyBodyFetcher.make_api_call_for_site(): all exceptions are swallowed, so makes no differencedeletionwatcher._check_batch(): this code appears to have been obsolete for over a year