TypeError when payload class is already a constant#2564
Merged
solnic merged 7 commits intogetsentry:masterfrom Feb 21, 2025
Merged
TypeError when payload class is already a constant#2564solnic merged 7 commits intogetsentry:masterfrom
solnic merged 7 commits intogetsentry:masterfrom
Conversation
solnic
requested changes
Feb 20, 2025
Collaborator
solnic
left a comment
There was a problem hiding this comment.
Thank you! I've left a couple of comments 🙂
`constantize` is basically an alias for `Object.const_get`, so why are we doing gymnastics to avail ourselves of it? https://github.com/rails/rails/blob/cf6ff17e9a3c6c1139040b519a341f55f0be16cf/activesupport/lib/active_support/inflector/methods.rb#L289
solnic
requested changes
Feb 20, 2025
The `constantize` logic needs to remain so long as this gem supports Ruby < 2.7. rails/rails@7057ccf
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
|
This file contains hidden or 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
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.
Description
When
Resque.inline = true, which is often used in an application's specs when testing a Resque job's business logic, thepayload["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-rubyno longer supports Ruby 2.4-2.6. According to this Rails commit,Object.const_getworks properly from Rails 2.7 on.