Skip to content

TypeError when payload class is already a constant#2564

Merged
solnic merged 7 commits intogetsentry:masterfrom
jgarber-cisco:payload-class-already-a-constant
Feb 21, 2025
Merged

TypeError when payload class is already a constant#2564
solnic merged 7 commits intogetsentry:masterfrom
jgarber-cisco:payload-class-already-a-constant

Conversation

@jgarber-cisco
Copy link
Copy Markdown
Contributor

@jgarber-cisco jgarber-cisco commented Feb 19, 2025

Description

When Resque.inline = true, which is often used in an application's specs when testing a Resque job's business logic, the payload["class"] that the Sentry hook gets is an actual class, not a string! I've added a spec for this case and fixed it by avoiding constantization if it's already a class.

Note: Reliance on ActiveSupport::Inflector#constantize can be removed if/when sentry-ruby no longer supports Ruby 2.4-2.6. According to this Rails commit, Object.const_get works properly from Rails 2.7 on.

Copy link
Copy Markdown
Collaborator

@solnic solnic left a comment

Choose a reason for hiding this comment

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

Thank you! I've left a couple of comments 🙂

@jgarber-cisco jgarber-cisco requested a review from solnic February 20, 2025 13:52
…tize"

This reverts commit 740011b.
@solnic says we need to support Rails <7 && Ruby <2.7.
The `constantize` logic needs to remain so long as this gem supports Ruby < 2.7. rails/rails@7057ccf
@jgarber-cisco jgarber-cisco requested a review from solnic February 20, 2025 16:52
Copy link
Copy Markdown
Collaborator

@solnic solnic left a comment

Choose a reason for hiding this comment

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

TY :)

@solnic solnic merged commit bd78c29 into getsentry:master Feb 21, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.46%. Comparing base (db975df) to head (86896fb).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2564      +/-   ##
==========================================
+ Coverage   64.11%   64.46%   +0.34%     
==========================================
  Files         123      123              
  Lines        4724     4672      -52     
==========================================
- Hits         3029     3012      -17     
+ Misses       1695     1660      -35     
Components Coverage Δ
sentry-ruby 60.09% <ø> (+0.24%) ⬆️
sentry-rails 59.82% <ø> (+0.60%) ⬆️
sentry-sidekiq 97.16% <ø> (ø)
sentry-resque 94.44% <100.00%> (+1.58%) ⬆️
sentry-delayed_job 95.65% <ø> (ø)
sentry-opentelemetry 99.31% <ø> (ø)
Files with missing lines Coverage Δ
sentry-resque/lib/sentry/resque.rb 100.00% <100.00%> (+2.22%) ⬆️

... and 35 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants