-
Notifications
You must be signed in to change notification settings - Fork 3
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
Do not report exceptions rescued by rails #138
Merged
AlanGabbianelli
merged 2 commits into
master
from
do-not-report-exceptions-rescued-by-ActionDispatch
Mar 9, 2020
Merged
Do not report exceptions rescued by rails #138
AlanGabbianelli
merged 2 commits into
master
from
do-not-report-exceptions-rescued-by-ActionDispatch
Mar 9, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TL;DR: This stops exceptions rescued by rails from appearing in Sentry. After upgrading `frontend` to rails 6, we started seeing this error: `Mime::Type::InvalidMimeType "charset=utf-8" is not a valid MIME type` Example here: https://www.sentry.io/organizations/govuk/issues/1549200925/?end=2020-03-06T12%3A00%3A23&environment=staging&project=202225&query=is%3Aunresolved+url%3Ahttps%3A%2F%2Fwww-origin.staging.govuk.digital%2Freport-an-unregistered-trader-or-business&start=2020-03-05T16%3A07%3A23&utc=true This is because, even though these errors are rescued by ActionDispatch, they still reach Sentry. Here's the explanation from Sentry's docs: > Rails catches exceptions in the ActionDispatch::ShowExceptions or > ActionDispatch::DebugExceptions middlewares, depending on the > environment. When rails_report_rescued_exceptions is true (it is by > default), Raven will report exceptions even when they are rescued by > these middlewares. So, in order to stop this behaviour, we initially took a double approach: - set that option to be false for `frontend` in [this PR](alphagov/frontend#2264) to stop all exceptions rescued by rails (not only `Mime::Type::InvalidMimeType`) from appearing in Sentry for `frontend` - explicitly added `Mime::Type::InvalidMimeType` to the list of excluded exceptions in [this PR](#137) to stop `Mime::Type::InvalidMimeType` from appearing in Sentry for all apps that depend on `govuk_app_config` Setting `rails_report_rescued_exceptions` to `false` here is better because it will apply this config to all apps that depend on `govuk_app_config`, making the two PRs above redundant and saving us from making this change in every app. Trello card: https://trello.com/c/Ik7ulDXQ/1768-3-upgrade-frontend-to-rails-6
thomasleese
reviewed
Mar 9, 2020
This was referenced Mar 9, 2020
thomasleese
approved these changes
Mar 9, 2020
Setting `config.rails_report_rescued_exceptions` to `false` makes having these exceptions in `config.excluded_exceptions` redundant. All the exceptions present in `config.action_dispatch.rescue_responses` can be removed from `config.excluded_exceptions`. See https://guides.rubyonrails.org/configuring.html#configuring-action-dispatch for the list of exceptions in `config.action_dispatch.rescue_responses`. Trello card: https://trello.com/c/Ik7ulDXQ/1768-3-upgrade-frontend-to-rails-6
AlanGabbianelli
force-pushed
the
do-not-report-exceptions-rescued-by-ActionDispatch
branch
from
March 9, 2020 12:38
11d0191
to
8f25109
Compare
thomasleese
approved these changes
Mar 9, 2020
AlanGabbianelli
deleted the
do-not-report-exceptions-rescued-by-ActionDispatch
branch
March 9, 2020 12:57
AlanGabbianelli
pushed a commit
to alphagov/frontend
that referenced
this pull request
Mar 9, 2020
This version of the gem stops exceptions rescued by rails from reaching Sentry. For more info on why and how, see alphagov/govuk_app_config#138 Trello card: https://trello.com/c/Ik7ulDXQ/1768-3-upgrade-frontend-to-rails-6
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR: This stops exceptions rescued by rails from appearing in Sentry.
After upgrading
frontend
to rails 6, we started seeing this error:Mime::Type::InvalidMimeType "charset=utf-8" is not a valid MIME type
Example here:
https://www.sentry.io/organizations/govuk/issues/1549200925/?end=2020-03-06T12%3A00%3A23&environment=staging&project=202225&query=is%3Aunresolved+url%3Ahttps%3A%2F%2Fwww-origin.staging.govuk.digital%2Freport-an-unregistered-trader-or-business&start=2020-03-05T16%3A07%3A23&utc=true
This is because, even though these errors are rescued by ActionDispatch,
they still reach Sentry. Here's the explanation from Sentry's docs:
So, in order to stop this behaviour, we initially took a double
approach:
frontend
inthis PR to stop all
exceptions rescued by rails (not only
Mime::Type::InvalidMimeType
)from appearing in Sentry for
frontend
Mime::Type::InvalidMimeType
to the list ofexcluded exceptions in
this PR to stop
Mime::Type::InvalidMimeType
from appearing in Sentry for all apps thatdepend on
govuk_app_config
Setting
rails_report_rescued_exceptions
tofalse
here is betterbecause it will apply this config to all apps that depend on
govuk_app_config
, making the two PRs above redundant and saving usfrom making this change in every app.
Setting
config.rails_report_rescued_exceptions
tofalse
makes havingthese exceptions in
config.excluded_exceptions
redundant.All the exceptions present in
config.action_dispatch.rescue_responses
can be removed from
config.excluded_exceptions
.See
https://guides.rubyonrails.org/configuring.html#configuring-action-dispatch
for the list of exceptions in
config.action_dispatch.rescue_responses
.Trello card: https://trello.com/c/Ik7ulDXQ/1768-3-upgrade-frontend-to-rails-6