{{ message }}
Fix boolean status methods to raise on error statuses instead of returning False#3456
Open
toroleapinc wants to merge 1 commit into
Open
Fix boolean status methods to raise on error statuses instead of returning False#3456toroleapinc wants to merge 1 commit into
toroleapinc wants to merge 1 commit into
Conversation
Add Requester.requestJsonAndBoolCheck() that correctly handles boolean API endpoints (204/404). Instead of silently returning False for error statuses like 401 (expired token) or 403 (no access), the new method raises the appropriate GithubException, preventing false negatives. Update PullRequest.is_merged() to use the new method as a first step. Other methods using the same pattern (return status == 204) can be migrated incrementally. Fixes PyGithub#2760 Signed-off-by: edvatar <88481784+toroleapinc@users.noreply.github.com>
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.

Problem
Methods like
PullRequest.is_merged()userequestJson()and checkstatus == 204to return a boolean. This silently returnsFalsefor any non-204 status, including error statuses like:This leads to false negatives — e.g.
is_merged()returnsFalsewhen the token has expired, even if the PR is actually merged.Solution
Add
Requester.requestJsonAndBoolCheck()that:Truefor the expected status (204)Falsefor the absent status (404)GithubExceptionfor all other statusesUpdated
PullRequest.is_merged()to use this method. Other methods using the samereturn status == 204pattern can be migrated incrementally.Fixes #2760