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

chore(sentry apps): Audit errors for token exchange process #83064

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Christinarlong
Copy link
Contributor

@Christinarlong Christinarlong commented Jan 7, 2025

tl;dr audited and wrapped all the errors in the token exchange process

Move all the token exchange process errors to sentryapp errors, update the tests to follow suit

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 7, 2025
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 88.33333% with 7 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ntry/sentry_apps/token_exchange/grant_exchanger.py 62.50% 3 Missing ⚠️
src/sentry/sentry_apps/token_exchange/refresher.py 57.14% 3 Missing ⚠️
src/sentry/sentry_apps/token_exchange/validator.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #83064       +/-   ##
===========================================
+ Coverage   56.21%   87.59%   +31.38%     
===========================================
  Files        9416     9446       +30     
  Lines      536122   536852      +730     
  Branches    21120    21120               
===========================================
+ Hits       301375   470258   +168883     
+ Misses     234387    66234   -168153     
  Partials      360      360               

@Christinarlong Christinarlong marked this pull request as ready for review January 8, 2025 21:43
@Christinarlong Christinarlong requested review from a team as code owners January 8, 2025 21:43

if not self._grant_is_active():
raise APIUnauthorized("Grant has already expired")
raise SentryAppIntegratorError(
APIUnauthorized("Grant has already expired"), status_code=403
Copy link
Member

Choose a reason for hiding this comment

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

Are we changing the status code for this, or is this just because we're now wrapping the error? Also is it worth using the same enums you're using in testing for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

APIUnauthorized has a built in status code of 403, but SentryAppIntegratorError's default status code is 400 and we use the status code attached to SentryAppIntegratorError.

er I'm a bit confused wdym by using the same enums you're using in testing for these like testing we raise a SentryAppIntegratorError ?

Copy link
Member

Choose a reason for hiding this comment

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

Ahh okay, so it's a side effect of the composition swallowing the status code then 😅

er I'm a bit confused wdym by using the same enums you're using in testing for these like testing we raise a SentryAppIntegratorError ?

Oh I just meant the drf status import in the test:
from rest_framework import serializers, status

APIUnauthorized("Invalid grant type"), status_code=status.HTTP_403_FORBIDDEN

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohhhhh, makes sense 👍

@getsantry
Copy link
Contributor

getsantry bot commented Jan 31, 2025

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added Stale and removed Stale labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants