bensheldon/good_job · error · ArgumentError

Expected an ActiveJob::Base instance, got #{active_job.class

Error message

Expected an ActiveJob::Base instance, got #{active_job.class}

What it means

Error "Expected an ActiveJob::Base instance, got #{active_job.class}" thrown in bensheldon/good_job.

Source

Thrown at lib/good_job/bulk.rb:77

      self.current_buffer = original_buffer
    end

    class Buffer
      def initialize
        @values = []
      end

      def capture
        original_buffer = Bulk.current_buffer
        Bulk.current_buffer = self
        yield
      ensure
        Bulk.current_buffer = original_buffer
      end

      def add(active_jobs, queue_adapter: nil)
        new_pairs = Array(active_jobs).map do |active_job|
          raise ArgumentError, "Expected an ActiveJob::Base instance, got #{active_job.class}" unless active_job.is_a?(ActiveJob::Base)

          adapter = queue_adapter || active_job.class.queue_adapter
          raise Error, "Jobs must have a Queue Adapter" unless adapter

          [active_job, adapter]
        end
        @values.append(*new_pairs)

        true
      end

      def enqueue
        Bulk.unbuffer do
          active_jobs_by_queue_adapter.each do |adapter, jobs|
            jobs = jobs.reject(&:provider_job_id) # Do not re-enqueue already enqueued jobs

            if adapter.respond_to?(:enqueue_all)
              unbulkable_jobs, bulkable_jobs = jobs.partition do |job|

View on GitHub (pinned to 5fcde48f87)

Solutions

  1. Enqueue only ActiveJob::Base instances with GoodJob::Bulk.
  2. Pass job instances, not classes or other objects, to GoodJob::Bulk.enqueue.

Example fix

GoodJob::Bulk.enqueue(MyJob.new(args), OtherJob.new)

When it happens

Trigger: Thrown at lib/good_job/bulk.rb:77 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bensheldon/good_job@5fcde48f87 (2026-08-23). Data as JSON: /api/errors/a2794209273c899b. Report an issue: GitHub.