/queue/enqueue — ARQ ‘function’ kwarg collision fix (2026-07-17)

Type: bugfix / decision Commit: entirely-api 3361fdf (pushed)

What was broken

POST /queue/enqueue 500’d for task_run_service — the only generic task in ALLOWED_TASKS — with "got multiple values for argument 'function'". task_run_service(ctx, module, function, kwargs) has a parameter literally named function, and routes/queue.py spread req.kwargs into enqueue_job(**kwargs), colliding with ARQ’s own first parameter (enqueue_job(function, *args, **kwargs), as wrapped by sentry-sdk’s ARQ integration). Broken since the route shipped. scheduler.py:_enqueue had already dodged the same collision by passing positionally.

Fix

  • routes/queue.py: new POSITIONAL_TASKS map — tasks whose param names collide with enqueue_job’s signature get their kwargs converted to positional args in declared order; unknown or missing required params return 400 at the route instead of failing asynchronously in the worker.
  • services/job_queue.py: enqueue() now accepts *args; docstring documents that task kwargs must not be named function or start with _.

Verified

  • Repro’d the 500 pre-fix, then post-rebuild: task_run_service enqueued and ran end-to-end (read-only probe services.job_queue.get_job, success=true, worker log “Ran services.job_queue.get_job: done”).
  • Kwarg-style tasks regression-checked (task_batch_cert_validate → success).
  • Same latent pattern exists in services/job_service.py:enqueue_job (kwarg spread), but its callers’ tasks (bulk cert/invoice/approve) have no colliding param names today.
  • job-queue scheduler