bensheldon/good_job · error · TypeError

Concurrency key must be a String; was a #{key.class}

Error message

Concurrency key must be a String; was a #{key.class}

What it means

Error "Concurrency key must be a String; was a #{key.class}" thrown in bensheldon/good_job.

Source

Thrown at lib/good_job/active_job_extensions/concurrency.rb:350

        end
      end

      # Existing or dynamically generated concurrency key
      # @return [Object] concurrency key
      def good_job_concurrency_key
        @good_job_concurrency_key || _good_job_concurrency_key
      end

      # Generates the concurrency key from the configuration
      # @return [Object] concurrency key
      def _good_job_concurrency_key
        return _good_job_default_concurrency_key unless self.class.good_job_concurrency_config.key?(:key)

        key = self.class.good_job_concurrency_config[:key]
        return if key.blank?

        key = instance_exec(&key) if key.respond_to?(:call)
        raise TypeError, "Concurrency key must be a String; was a #{key.class}" unless VALID_TYPES.any? { |type| key.is_a?(type) }

        key
      end

      # Generates the default concurrency key when the configuration doesn't provide one
      # @return [String] concurrency key
      def _good_job_default_concurrency_key
        self.class.name.to_s
      end
    end
  end
end

View on GitHub (pinned to 5fcde48f87)

Solutions

  1. Ensure the concurrency key is a String when the job is performed.
  2. Convert the key to a String before enqueueing or in the key block.

Example fix

key = key.to_s

When it happens

Trigger: Thrown at lib/good_job/active_job_extensions/concurrency.rb:350 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/1742c6d65b219875. Report an issue: GitHub.