sentry-rails: excluded_exceptions triggers a Rails deprecation warning for ActionController::InvalidAuthenticityToken

Open Beginner friendly
#3,228 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rails, ruby
Domain
backend

Research direction

Grep the sentry-rails gem for Sentry::Rails::IGNORE_DEFAULT to find the default exclusion list, then read Sentry::Configuration#excluded_exception_classes, which resolves each name via Object.const_get. The change is to stop listing ActionController::InvalidAuthenticityToken when ActionController::InvalidCrossOriginRequest is already present and defined, so the deprecated constant is never resolved. Done looks like capturing an exception under Rails main with no DEPRECATION WARNING, plus the existing configuration specs still passing.

Written by the indexing model from the issue text.

Description

Bug Ruby Waiting for: Product Owner

Rails main (8.2) deprecates ActionController::InvalidAuthenticityToken in favour of ActionController::InvalidCrossOriginRequest (release notes). The old name is now a deprecated constant that warns when it is resolved.

Sentry::Rails::IGNORE_DEFAULT still lists "ActionController::InvalidAuthenticityToken", and Sentry::Configuration#excluded_exception_classes resolves every name with Object.const_get. So the first exception that Sentry captures in each process prints:

DEPRECATION WARNING: ActionController::InvalidAuthenticityToken has been deprecated and will be removed in Rails 9.0. Use ActionController::InvalidCrossOriginRequest instead.

Versions: sentry-ruby / sentry-rails 7.2.0 (7.3.0 has the same list), Rails main.

Suggested fix: leave "ActionController::InvalidAuthenticityToken" out of the default list when ActionController::InvalidCrossOriginRequest is defined, because the list already holds that name and the old name refers to the same class.

Workaround:

Sentry::Configuration.after(:initialize) do
  excluded_exceptions.delete("ActionController::InvalidAuthenticityToken")
end
Dominant language
Ruby
Stars
990
Forks
553
Avg merge
1d 19h
Merged PRs (30d)
31

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-ruby

All issues in getsentry/sentry-ruby

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.