Skip to content
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

Fixed constantize issue #2243

Closed
wants to merge 1 commit into from

Conversation

saviokmua
Copy link

Thanks for your Pull Request 🎉

Please keep these instructions in mind so we can review it more efficiently:

  • Add the references of all the related issues/PRs in the description
  • Whether it's a new feature or a bug fix, make sure they're covered by new test cases
  • If this PR contains any refactoring work, please give it its own commit(s)
  • Finally, please add an entry to the corresponding changelog

Other Notes

  • We squash all commits before merging
  • We generally review new PRs within a week
  • If you have any question, you can ask for feedback in our discord community first

Description

Describe your changes:

Fixed constantize issue

got #<NoMethodError: undefined method constantize' for MyWorker:Class`

@@ -32,7 +32,7 @@ def record(queue, worker, payload, &block)

finish_transaction(transaction, 200)
rescue Exception => exception
klass = payload['class'].constantize
klass = payload['class'].to_s.constantize
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the class attribute is already a class, then we don't want to re-constantize it.

Suggested change
klass = payload['class'].to_s.constantize
klass = payload['class']
if klass.is_a(String)
klass = klass.constantize
end

Copy link

codecov bot commented Feb 12, 2024

Codecov Report

Merging #2243 (6d388aa) into master (3377a28) will increase coverage by 0.02%.
Report is 2 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2243      +/-   ##
==========================================
+ Coverage   97.41%   97.43%   +0.02%     
==========================================
  Files         102      102              
  Lines        3823     3825       +2     
==========================================
+ Hits         3724     3727       +3     
+ Misses         99       98       -1     
Components Coverage Δ
sentry-ruby 98.10% <ø> (+<0.01%) ⬆️
sentry-rails 95.05% <ø> (ø)
sentry-sidekiq 94.70% <ø> (ø)
sentry-resque 93.65% <100.00%> (+1.58%) ⬆️
sentry-delayed_job 95.60% <ø> (ø)
sentry-opentelemetry 100.00% <ø> (ø)
Files Coverage Δ
sentry-resque/lib/sentry/resque.rb 100.00% <100.00%> (+2.63%) ⬆️

... and 11 files with indirect coverage changes

@st0012
Copy link
Collaborator

st0012 commented Feb 12, 2024

Thanks for the PR. Is it possible to write a test case for this fix?

dentarg added a commit to dentarg/raven-ruby that referenced this pull request Feb 17, 2024
@dentarg
Copy link
Contributor

dentarg commented Feb 17, 2024

Is it possible to write a test case for this fix?

There are already tests covering this but they are not catching this due to rails being required, I've fixed it in #2248

dentarg added a commit to dentarg/raven-ruby that referenced this pull request Feb 17, 2024
@st0012 st0012 closed this in #2248 Feb 20, 2024
st0012 pushed a commit that referenced this pull request Feb 20, 2024
* Allow custom Redis instance for tests

You probably don't want the tests to use the same Redis you use for any
app development.

Maybe you want to use Docker with custom port:

    docker run --rm -it -p 16379:6379 redis:6

* Run sentry-resque specs without Rails

Tests and fixes #2243

* Run with latest `psych`

I think ruby/psych#655 was resolved long ago

* Note `constantize` sentry-resque fix in CHANGELOG
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.

3 participants