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

be more flexible with responses coming through repo_auth_custom_exception_handler #659

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

nora-codecov
Copy link
Contributor

Purpose/Motivation

This code introduced an issue when it was added, sentry entry here. lots of responses were getting a KeyError because they didn't have the format that was expected.

What does this PR do?

Makes the logic in the function much more cautious, does several checks instead of making assumptions

@nora-codecov nora-codecov requested a review from a team as a code owner July 3, 2024 23:32
Copy link

codecov-public-qa bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.58%. Comparing base (4f74318) to head (f900bb9).

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #659   +/-   ##
=======================================
  Coverage   91.58%   91.58%           
=======================================
  Files         628      628           
  Lines       16698    16698           
=======================================
  Hits        15293    15293           
  Misses       1405     1405           
Flag Coverage Δ
unit 91.58% <100.00%> (ø)
unit-latest-uploader 91.58% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
codecov_auth/authentication/repo_auth.py 95.81% <100.00%> (ø)

Impacted file tree graph

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.94%. Comparing base (4f74318) to head (f900bb9).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##               main       #659   +/-   ##
===========================================
  Coverage   95.94000   95.94000           
===========================================
  Files           806        806           
  Lines         18015      18015           
===========================================
  Hits          17285      17285           
  Misses          730        730           
Flag Coverage Δ
unit 91.58% <100.00%> (ø)
unit-latest-uploader 91.58% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +46 to +53
if (
response is not None
and hasattr(response, "status_code")
and response.status_code == 401
and hasattr(response, "data")
):
Copy link
Contributor

Choose a reason for hiding this comment

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

these hasattrs are making me think we're sometimes getting something that is a totally different type than we're expecting. i am confused

the KeyErrors in sentry were just about that detail key, were you also seeing errors about status_code and data not even existing? the link in the PR description is just to the project, not a specific issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you right - I think lots of types of exceptions are flowing through here but this is an overreaction, to make it fully bomb-proof, so that this type of issue can't arise again. It's doing the safe checks for every element of the object that we check - just because I was thinking, what if I just patch this KeyError with detail and another similar issue arises with this block.

What do you think - should I pull it back to just the KeyError, or should I leave this super cautious logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some in-line comments to reflect my thoughts here, but going to merge so that the issue can be fixed.

@codecov-notifications
Copy link

codecov-notifications bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.58%. Comparing base (4f74318) to head (f900bb9).

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main     #659   +/-   ##
=======================================
  Coverage   91.58%   91.58%           
=======================================
  Files         628      628           
  Lines       16698    16698           
=======================================
  Hits        15293    15293           
  Misses       1405     1405           
Flag Coverage Δ
unit 91.58% <100.00%> (ø)
unit-latest-uploader 91.58% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
codecov_auth/authentication/repo_auth.py 95.81% <100.00%> (ø)

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@nora-codecov nora-codecov added this pull request to the merge queue Jul 8, 2024
Merged via the queue into main with commit 30a9b98 Jul 8, 2024
21 of 22 checks passed
@nora-codecov nora-codecov deleted the nora/support-bug-2 branch July 8, 2024 23:02
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.

2 participants