Class: Sidekiq::NormalizeArgsMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/normalize_args_middleware.rb

Overview

Middleware to normalize hash arguments to use string keys consistently.

Sidekiq serializes job arguments to JSON, which always produces string keys.
However, the lock digest for sidekiq-unique-jobs is computed BEFORE serialization,
using the original Ruby hash. This means:

perform_async(delivery_id: 123) # symbol key
perform_async("delivery_id" => 123) # string key

Could produce different lock digests, causing duplicate jobs to slip through.

This middleware normalizes hash arguments to string keys on both client and server:

  • Client: Ensures consistent lock digest computation
  • Server: Ensures workers receive consistent hash format

Workers can still use symbol access via with_indifferent_access, but this
removes the ambiguity at the source.

Defined Under Namespace

Classes: Client, Server