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

未关闭 适合新手
#3,228 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rails, ruby
领域
backend

调研方向

在 sentry-rails gem 中 grep Sentry::Rails::IGNORE_DEFAULT,找到默认排除列表,然后阅读 Sentry::Configuration#excluded_exception_classes,它通过 Object.const_get 解析每个名称。改动是:当 ActionController::InvalidCrossOriginRequest 已存在且已定义时,不再列出 ActionController::InvalidAuthenticityToken,这样这个已弃用的常量就永远不会被解析。完成的标准是:在 Rails main 下捕获异常且没有 DEPRECATION WARNING,同时现有的 configuration specs 仍然通过。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
Ruby
星标
990
派生
553
平均合并
1 天 19 小时
30 天内合并 PR
31

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-ruby 的其他 Issue

查看 getsentry/sentry-ruby 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。