bensheldon/good_job · error · ArgumentError

Properties must be a Hash

Error message

Properties must be a Hash

What it means

Error "Properties must be a Hash" thrown in bensheldon/good_job.

Source

Thrown at app/models/good_job/batch_record.rb:124

    class PropertySerializer
      def self.dump(value)
        ActiveJob::Arguments.serialize([value]).first
      end

      def self.load(value)
        ActiveJob::Arguments.deserialize([value]).first
      end
    end

    if Rails.gem_version < Gem::Version.new('7.1.0.alpha')
      serialize :serialized_properties, PropertySerializer, default: -> { {} }
    else
      serialize :serialized_properties, coder: PropertySerializer, default: -> { {} }
    end
    alias_attribute :properties, :serialized_properties

    def properties=(value)
      raise ArgumentError, "Properties must be a Hash" unless value.is_a?(Hash)

      self.serialized_properties = value
    end

    def jobs_finished?
      self.class.jobs_finished_at_migrated? ? jobs_finished_at : finished_at
    end

    def jobs_finished_at
      self.class.jobs_finished_at_migrated? ? self[:jobs_finished_at] : self[:finished_at]
    end

    private

    def advisory_lock_maybe(value, &block)
      if value
        transaction { with_advisory_lock(function: "pg_advisory_xact_lock", &block) }
      else

View on GitHub (pinned to 5fcde48f87)

Solutions

  1. Pass a Hash for the properties argument when building a BatchRecord.
  2. Ensure the properties value is a Hash, not an Array, String, or nil.

Example fix

GoodJob::BatchRecord.new(properties: { key: 'value' })

When it happens

Trigger: Thrown at app/models/good_job/batch_record.rb:124 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/198e686311aeb0ad. Report an issue: GitHub.