-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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): Improve Sentry App Errors #81877
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #81877 +/- ##
==========================================
+ Coverage 80.33% 80.60% +0.27%
==========================================
Files 7272 7259 -13
Lines 321230 324846 +3616
Branches 20941 20793 -148
==========================================
+ Hits 258051 261857 +3806
+ Misses 62784 62590 -194
- Partials 395 399 +4 |
return Response( | ||
{"error": e.message}, | ||
{"error": str(e)}, |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Stack trace information
Stack trace information
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 27 days ago
To fix the problem, we should ensure that detailed error information is logged on the server while returning a generic error message to the user. This can be achieved by logging the exception details and returning a user-friendly error message in the response.
- Modify the code to log the exception details using the
logger
and return a generic error message to the user. - Ensure that the logging captures sufficient information for debugging purposes without exposing sensitive details to the end user.
-
Copy modified line R46 -
Copy modified line R48
@@ -45,4 +45,5 @@ | ||
except (SentryAppIntegratorError, SentryAppError) as e: | ||
logger.error("Error occurred while getting Select FormField options: %s", str(e)) | ||
return Response( | ||
{"error": str(e)}, | ||
{"error": "An error occurred while processing your request."}, | ||
status=400, |
trigger_sentry_app_action_creators_for_incidents(serialized_data) | ||
except (SentryAppError, SentryAppIntegratorError) as e: | ||
return Response( | ||
str(e), |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 26 days ago
To fix the problem, we need to ensure that the exception messages returned to the user do not contain sensitive information. Instead, we should log the detailed error message on the server and return a generic error message to the user. This can be achieved by modifying the exception handling blocks to log the error and return a generic message.
-
Copy modified line R42 -
Copy modified line R44 -
Copy modified line R62 -
Copy modified line R64
@@ -41,4 +41,5 @@ | ||
except (SentryAppError, SentryAppIntegratorError) as e: | ||
sentry_sdk.capture_exception(e) | ||
return Response( | ||
str(e), | ||
"An error occurred while processing your request.", | ||
status=status.HTTP_400_BAD_REQUEST, | ||
@@ -60,4 +61,5 @@ | ||
except (SentryAppError, SentryAppIntegratorError) as e: | ||
sentry_sdk.capture_exception(e) | ||
return Response( | ||
{"actions": [str(e)]}, | ||
{"actions": ["An error occurred while processing your request."]}, | ||
status=status.HTTP_400_BAD_REQUEST, |
|
||
except (SentryAppError, SentryAppIntegratorError) as e: | ||
return Response( | ||
{"actions": [str(e)]}, |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 26 days ago
To fix the problem, we need to ensure that the exception messages returned to the user do not contain sensitive information. Instead, we should log the detailed exception information and return a generic error message to the user. This can be achieved by modifying the exception handling blocks to log the exception and return a generic error message.
-
Copy modified line R61 -
Copy modified line R63
@@ -60,4 +60,5 @@ | ||
except (SentryAppError, SentryAppIntegratorError) as e: | ||
sentry_sdk.capture_exception(e) | ||
return Response( | ||
{"actions": [str(e)]}, | ||
{"actions": ["An error occurred while processing the request."]}, | ||
status=status.HTTP_400_BAD_REQUEST, |
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 "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Introduces two classes to represent Sentry App exceptions:
SentryAppError
should be used to represent client side errors like failed validation. For the webhook, these should not be sent to the integrator.SentryAppIntegratorError
is used to represent errors between Sentry & the integrator, i.e connection failed, integrator response is incorrect etc. These should be sent to the integrator for the webhook.For this PR, we want to start wrapping errors in the SentryApp flows with these distinctions. And then in the endpoints we want to catch these two specific errors and return the error message. More info here in notion
This PR is kinda two PRs in one, because I wanted to refactor the alert rule creation flow for Sentry Apps. Currently creating an alert rule for sentry apps has a really weird flow where we don't raise errors until very late.
Context for Alert Rule Sentry App creation: Notion doc