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

Sidekiq::CurrentAttributes overwriting values on retry #5692

Closed
fschwahn opened this issue Dec 9, 2022 · 1 comment
Closed

Sidekiq::CurrentAttributes overwriting values on retry #5692

fschwahn opened this issue Dec 9, 2022 · 1 comment

Comments

@fschwahn
Copy link

fschwahn commented Dec 9, 2022

I'm running into a problem where Sidekiq::CurrentAttributes overwrites existing attributes when triggering a retry from Sidekiq UI. There are a few preconditions to trigger this.

  1. I'm using Devise for authentication
  2. Sidekiq UI is guarded by devise, eg:
authenticate :user, ->(u) { u.admin? } do
  mount Sidekiq::Web => '/sidekiq'
end
  1. Current is set in a warden callback, eg:
Warden::Manager.prepend_after_set_user do |user, auth, opts|
  Current.user_id = user.id
end

That leads to the cattr-hash being overwritten with the user id of my admin user when clicking "Retry" in the admin interface. The reason for this is c92a521, which fixed #5090. Both issues could be solved by doing nothing if a cattr-hash already exists, eg. just guarding with unless job.key?("cattr").

Maybe there's a different story why you decided to merge the hashes instead, but this lead to some quite surprising results on our end.

@mperham
Copy link
Collaborator

mperham commented Dec 9, 2022

Oh wow, that's a crazy sequence of events but I can see how that would happen. Nice debugging!

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

No branches or pull requests

2 participants