Repository navigation
[FIX] Resolve ContentFile subscript TypeError when fetching issue template (#1261) - #1262
Open
garv-sanveria wants to merge 1 commit into
Open
garv-sanveria wants to merge 1 commit into
garv-sanveria wants to merge 1 commit into
Conversation
garv-sanveria
requested review from
canihavesomecoffee and
thealphadollar
as code owners
November 5, 2026 22:04
|
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.



In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Summary
Fixes #1261
When a user completes a sample upload with the option to report an issue to GitHub (
form.report.data == 'y'),mod_upload/controllers.pyfetches the repository issue template viarepository.get_contents(".github/ISSUE_TEMPLATE.md").Since migrating to
PyGithub,get_contents()returns agithub.ContentFile.ContentFileobject rather than a dictionary. Subscriptingresponse['content']andresponse['encoding']raises:This causes an unhandled 500 Internal Server Error, preventing the issue from being created on GitHub and failing the upload redirection.
Changes
mod_upload/controllers.py: Usedresponse.decoded_content.decode('utf-8')provided by PyGithub'sContentFileto decode the template string directly instead of indexing into the object and running manual base64 decoding.tests/test_upload/test_controllers.py: Updatedtest_processto mockget_contentswith an actualContentFileinstance containingdecoded_contentrather than a plain dictionary, preventing mock-reality drift and protecting against future regressions.Testing & Verification
pytest tests/test_upload/test_controllers.py(all 12 tests passed).pycodestyle,isort,pydocstyle, andmypy.