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(sentryapps): better logging and errors for select requester #79377

Merged
merged 7 commits into from
Oct 22, 2024

Conversation

Christinarlong
Copy link
Contributor

@Christinarlong Christinarlong commented Oct 18, 2024

Ok more like let's differentiate between when we fail due to external requests failing or due to validation errors
Changes:

  • Endpoint now throws a ValidationError if we fail to validate the resp or the resp is missing fields
  • APIError is only thrown if the request fails
  • We still only return 400s so there should be no client side changes
  • Update tests to reflect the new exceptions
  • Make empty arrays valid response

@Christinarlong Christinarlong marked this pull request as ready for review October 18, 2024 19:57
@Christinarlong Christinarlong requested a review from a team October 18, 2024 19:57
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 18, 2024
@Christinarlong Christinarlong enabled auto-merge (squash) October 18, 2024 19:57
},
)
raise
Copy link
Member

Choose a reason for hiding this comment

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

now that we aren't swallowing this exception, do we gracefully handle it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good pt, I just added a distinction to check now, if we get ApiError -> we return a message about validation failure and if the request to the webhook goes wrong we return a somewhat generic message and log the error.

/~https://github.com/getsentry/sentry/pull/79377/files#diff-7e1a5ec942c78dda796710a42c8a675441de74e2bdfa4653344b6fd711e73dcfR40-R51

Copy link

codecov bot commented Oct 19, 2024

Codecov Report

Attention: Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ps/api/endpoints/installation_external_requests.py 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #79377       +/-   ##
===========================================
+ Coverage   57.01%   78.35%   +21.33%     
===========================================
  Files        7114     7125       +11     
  Lines      314446   315158      +712     
  Branches    51416    51510       +94     
===========================================
+ Hits       179292   246950    +67658     
+ Misses     130529    61739    -68790     
- Partials     4625     6469     +1844     

@iamrajjoshi iamrajjoshi requested a review from a team October 21, 2024 17:45
"install_uuid": self.install.uuid,
"project_slug": self.project_slug,
"uri": self.uri,
"url": url,
Copy link
Member

Choose a reason for hiding this comment

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

isn't uri enough for debugging here? what added value does url have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the final url would come in handy in checking who we are contacting, and what the final query stirng is (since for this request we tend to have a bunch of query params).
It is somewhat redundant with the uri though, so I'd probably prefer to keep the url to debug with

@@ -241,6 +242,6 @@ def prepare_ui_component(
component=component, install=installation, project_slug=project_slug, values=values
).run()
return component
except APIError:
except (APIError, ValidationError):
# TODO(nisanthan): For now, skip showing the UI Component if the API requests fail
Copy link
Member

Choose a reason for hiding this comment

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

Lol! This TODO seems very old and important. Basically what to do here is to return the error and surface it to the user. Future PRs though.

Copy link
Member

@sentaur-athena sentaur-athena left a comment

Choose a reason for hiding this comment

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

Let's merge this :D It would make my life much easier as we have two customers waiting to see why their app is broken.

@Christinarlong Christinarlong merged commit e38ab01 into master Oct 22, 2024
50 of 51 checks passed
@Christinarlong Christinarlong deleted the add-more-logging-select-req branch October 22, 2024 22:21
Copy link

sentry-io bot commented Oct 23, 2024

Suspect Issues

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

  • ‼️ ValidationError: Invalid response format for SelectField in id=39357 scope_list=['event:read'] application_id=6569... sentry.api.sentry_app_components.get View Issue
  • ‼️ UnboundLocalError: cannot access local variable 'url' where it is not associated with a value sentry.api.sentry_app_components.get View Issue
  • ‼️ ValidationError: Invalid response format for SelectField in id=81605 scope_list=['event:read', 'event:write', 'org... sentry.api.sentry_app_components.get View Issue

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

@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants