Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Requester.__createException robust against missing message and body #2159

Merged

Conversation

EnricoMi
Copy link
Collaborator

@EnricoMi EnricoMi commented Jan 13, 2022

This adds tests for Requester.__createException while making this method robust against output missing "message" and output = None for all status.

Note: This simplifies logic while making BadCredentialsException, BadUserAgentException and UnknownObjectException case-insensitive to the message.

Fixes #1399 and #2158.

Note: Add that extra message from #2127 to tests.Requester.testShouldCreateRateLimitExceededException, either in that PR or here, whatever gets merged last.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2022

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (9f52e94) 98.68% compared to head (d7357a6) 98.68%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2159   +/-   ##
=======================================
  Coverage   98.68%   98.68%           
=======================================
  Files         117      117           
  Lines       11825    11826    +1     
=======================================
+ Hits        11670    11671    +1     
  Misses        155      155           
Impacted Files Coverage Δ
github/Requester.py 97.52% <100.00%> (+<0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@EnricoMi EnricoMi force-pushed the branch-fix-error-in-createException branch from e508688 to 563ad66 Compare December 22, 2022 07:07
@EnricoMi EnricoMi force-pushed the branch-fix-error-in-createException branch from 563ad66 to 07fd134 Compare March 1, 2023 13:52
@EnricoMi
Copy link
Collaborator Author

EnricoMi commented Mar 1, 2023

@s-t-e-v-e-n-k what do you think, can we get this merged?

@EnricoMi EnricoMi force-pushed the branch-fix-error-in-createException branch from 07fd134 to 1c2da8b Compare March 21, 2023 07:08
@EnricoMi EnricoMi requested a review from JLLeitschuh June 7, 2023 06:57
Copy link
Collaborator

@JLLeitschuh JLLeitschuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -452,26 +452,26 @@ def __customConnection(self, url):
return cnx

def __createException(self, status, headers, output):
if status == 401 and output.get("message") == "Bad credentials":
message = output.get("message", "").lower() if output is not None else ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea making this case insensitive! 👍

@EnricoMi EnricoMi merged commit 7be3f76 into PyGithub:master Jun 13, 2023
7 checks passed
@EnricoMi EnricoMi deleted the branch-fix-error-in-createException branch June 13, 2023 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting AttributeError: 'NoneType' object has no attribute 'startswith' when trying to get the repo_name
4 participants