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

Unable to use labels with kwargs in job initializer #1350

Open
gap777 opened this issue May 14, 2024 · 2 comments
Open

Unable to use labels with kwargs in job initializer #1350

gap777 opened this issue May 14, 2024 · 2 comments

Comments

@gap777
Copy link
Contributor

gap777 commented May 14, 2024

Hi,
Just trying out labels, and it appears that if I have kwargs in the initializer of my jobs, I can't use labels.

My job:

class TestJob < ApplicationJob
    include GoodJob::ActiveJobExtensions::Concurrency
    include GoodJob::ActiveJobExtensions::Labels

  def perform(kwarg1:, kwarg2:)
     good_job_labels << did_the_thing? ? 'Foo' : 'Bar'
  end

I get this in the error logs:

wrong number of arguments (given 1, expected 0; required keywords: kwarg1, kwarg2)
@bensheldon
Copy link
Owner

This is an Active Job thing: ActiveJob::Base#initialize should never have its method signature changed. I think you mean to customize the #perform signature to pass parameters to a job.

@gap777
Copy link
Contributor Author

gap777 commented May 14, 2024

@bensheldon 🤦 I created that example for this, trying to reproduce a more complicated example in my codebase. I don't have that obvious mistake in the real thing. ;-)

But still... I'm seeing that error about wrong number of arguments for perform when I add in the labels mixin.
Can you try that on your end, with a perform having kwargs and the label mixin present?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Inbox
Development

No branches or pull requests

2 participants