bensheldon/good_job · error · TypeError

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

Error message

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

What it means

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

Source

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

            perform_throttle = resolve_throttle(job, @perform_throttle)
            return nil unless perform_limit || perform_throttle

            check_perform(perform_limit, perform_throttle, job, resolved_key, resolved_label)
          end
        end

        private

        def key_explicit?
          !@key.equal?(GoodJob::NONE)
        end

        def resolve_key(job)
          if key.blank?
            "label:#{resolve_label(job)}"
          else
            key_value = @key.respond_to?(:call) ? job.instance_exec(&@key) : @key
            raise TypeError, "Concurrency key must be a String; was a #{key_value.class}" if key_value.present? && VALID_TYPES.none? { |type| key_value.is_a?(type) }

            key_value
          end
        end

        def resolve_label(job)
          return if @label.blank?

          @label.respond_to?(:call) ? job.instance_exec(&@label) : @label
        end

        def resolve_limit(job, value)
          return nil if value.nil?

          value = job.instance_exec(&value) if value.respond_to?(:call)
          value = nil unless value.present? && (0...Float::INFINITY).cover?(value)
          value
        end

View on GitHub (pinned to 5fcde48f87)

Solutions

  1. Return a String from the concurrency key lambda in good_job_control_concurrency_with.
  2. Convert the key value to a String, e.g. call .to_s in the key block.

Example fix

good_job_control_concurrency_with key: -> { arguments.first.to_s }

When it happens

Trigger: Thrown at lib/good_job/active_job_extensions/concurrency.rb:66 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/11734b1762bffbfb. Report an issue: GitHub.