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(snetry apps): Make SentryAppSentryErrors for Sentry side errors #83080

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

Christinarlong
Copy link
Contributor

@Christinarlong Christinarlong commented Jan 8, 2025

tl:dr This PR adds a new error type for Sentry side errors that shouldnt be sent to the integrator but still should be handled gracefully. So we can distinguish between truly Unhandled exceptions, and exceptions we have audited and thought about.

Context: Currently with only SentryAppErrors (client side errors) & SentryAppIntegratorErrors (integrator side errors) if we have a non wrapped error (i.e our fault error) then it will go through the default django rest_framework exception handler. This is okay for certain errors like authentication (i.e children of APIException) which rest_framework handles gracefully. However, if the exception does not inherit from APIException, they will be considered 'Unhandled' in Sentry.

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

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/sentry_apps/api/bases/sentryapps.py 60.00% 2 Missing ⚠️
...try_apps/external_issues/external_issue_creator.py 50.00% 1 Missing ⚠️
src/sentry/sentry_apps/utils/errors.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #83080      +/-   ##
==========================================
- Coverage   87.59%   87.58%   -0.01%     
==========================================
  Files        9423     9428       +5     
  Lines      536407   536529     +122     
  Branches    21120    21120              
==========================================
+ Hits       469839   469911      +72     
- Misses      66209    66259      +50     
  Partials      359      359              

@Christinarlong Christinarlong marked this pull request as ready for review January 8, 2025 21:19
@Christinarlong Christinarlong requested review from a team as code owners January 8, 2025 21:19
Comment on lines -48 to -63
try:
external_issue = ExternalIssueCreator(
install=installation,
group=group,
web_url=data["webUrl"],
project=data["project"],
identifier=data["identifier"],
).run()
except Exception as e:
error_id = capture_exception(e)
return Response(
{
"error": f"An issue occured while trying to create external issue. Sentry error ID: {error_id}"
},
status=500,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously we had an exception catcher in the endpoint and because we determined any errors happening from this block would be our fault we responded here. Now we can use the top level error handler to do that and let the exception go up.

error_id = sentry_sdk.capture_exception(exception)
return Response(
{
"error": f"An issue occured during the Sentry App process. Sentry error ID: {error_id}"
Copy link
Member

Choose a reason for hiding this comment

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

nit: customers don't know what a sentry app is, that's our internal term. Want to use something like "integration"?

@Christinarlong Christinarlong merged commit 62bcff6 into master Jan 8, 2025
48 checks passed
@Christinarlong Christinarlong deleted the christinarlong/add-sentry-app-sentry-errors branch January 8, 2025 22:04
Copy link

sentry-io bot commented Jan 9, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ SentryAppSentryError: OperationalError('server closed the connection unexpectedly\n\tThis probably means the server ter... /api/0/sentry-app-installations/{uuid}/external... View Issue

Did you find this useful? React with a 👍 or 👎

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