ObanDoctor.Check.Worker.UniqueWithoutKeys (oban_doctor v0.2.2)

Copy Markdown View Source

Checks for workers with unique configuration but no explicit keys option.

When using unique: [fields: [:args]] without specifying keys, Oban uses all fields from the job args for uniqueness. This can be problematic if:

  1. Args contain dynamic fields (timestamps, UUIDs) that should be ignored
  2. You want uniqueness based on only specific business identifiers

How to fix

Add explicit keys to specify which args matter for uniqueness:

use Oban.Worker,
  queue: :default,
  unique: [fields: [:args], keys: [:user_id, :action]]

See Oban unique jobs.

Configuration

In .oban_doctor.exs:

checks: [
  unique_without_keys: [
    # Disable the check entirely
    enabled: false,

    # Or exclude specific workers from this check
    excluded_workers: [MyApp.Workers.LegacyWorker]
  ]
]