Fix: add safe decode_file fallback for “encoding: none” and refactor callers to use it. - #820
Merged
Merged
Conversation
…ed all internal uses of .decoded_content.decode() to call decode_file instead.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #820 +/- ##
==========================================
- Coverage 58.58% 58.08% -0.51%
==========================================
Files 14 14
Lines 1910 1930 +20
==========================================
+ Hits 1119 1121 +2
- Misses 791 809 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
This message was generated by git-bob (version: 0.27.0, model: openai:gpt-5-2025-08-07, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.
This PR fixes Issue #819 by handling GitHub’s “encoding: none” responses that caused PyGithub’s decoded_content assertion to fail. I added a robust decode_file() that first tries the standard path and, on assertion failure, falls back to downloading via download_url or the Git blob API, preserving the existing behavior of raising UnicodeDecodeError for binary content. I then refactored internal callers to use decode_file() instead of directly accessing decoded_content.decode() in get_repository_file_contents, rename_file_in_repository, and copy_file_in_repository.
closes #819