fix: Add requestJsonAndCheck204 to properly handle 204 status checks#3461
Open
wavebyrd wants to merge 1 commit intoPyGithub:mainfrom
Open
fix: Add requestJsonAndCheck204 to properly handle 204 status checks#3461wavebyrd wants to merge 1 commit intoPyGithub:mainfrom
wavebyrd wants to merge 1 commit intoPyGithub:mainfrom
Conversation
Methods that check for 204 status now properly raise exceptions for error codes (401, 403, 500, etc.) while still allowing 404 to return False. This fixes the issue where methods like is_merged() would return False instead of raising an exception when authentication fails. Updated methods: - PullRequest.is_merged() - NamedUser.has_in_following() - Repository.create_repository_dispatch() The pattern is established - remaining methods can be updated similarly. Fixes PyGithub#2760 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
|
Ping - this fixes 204 status handling in API checks. Ready for review! |
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
Methods that check for 204 status now properly raise exceptions for error codes (401, 403, 500, etc.) while still allowing 404 to return False.
Problem
As described in #2760, methods like
is_merged()userequestJsonand checkstatus == 204. This causes:is_mergedreturnsFalseif credentials are expiredSolution
Added a new
requestJsonAndCheck204()method inRequester.pythat:Truefor status 204 (success)Falsefor status 404 (not found - valid response for "not merged")Changes
requestJsonAndCheck204()method toRequesterPullRequest.is_merged()NamedUser.has_in_following()Repository.create_repository_dispatch()Note
This PR establishes the pattern. There are ~40 other methods that use
status == 204that could be updated similarly. I can update them all if the maintainers approve this approach, or they can be updated incrementally.Fixes #2760
🤖 Generated with Claude Code