Jump to solution
Verify

The Fix

pip install celery==4.4.6

Based on closed celery/celery issue #6155 · PR/commit linked

Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.

Jump to Verify Open PR/Commit
@@ -144,7 +144,7 @@ def get(self, key): return None - def set(self, key, value, state): + def set(self, key, value): """Insert a doc with value into task attribute and _key as key."""
repro.py
celery_default_1 | [2020-06-04 19:51:47,723: ERROR/MainProcess] Pool callback raised exception: TypeError('set() takes 3 positional arguments but 4 were given',) celery_default_1 | Traceback (most recent call last): celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/billiard/pool.py", line 1796, in safe_apply_callback celery_default_1 | fun(*args, **kwargs) celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/celery/worker/request.py", line 528, in on_failure celery_default_1 | store_result=self.store_errors, celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/celery/backends/base.py", line 169, in mark_as_failure celery_default_1 | traceback=traceback, request=request) celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/celery/backends/base.py", line 443, in store_result celery_default_1 | request=request, **kwargs) celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/celery/backends/base.py", line 858, in _store_result celery_default_1 | self.set(self.get_key_for_task(task_id), self.encode(meta), state) celery_default_1 | TypeError: set() takes 3 positional arguments but 4 were given
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install celery==4.4.6\nWhen NOT to use: This fix should not be applied if the application relies on the state argument for backend operations.\n\n

Why This Fix Works in Production

  • Trigger: TypeError: set() takes 3 positional arguments but 4 were given
  • Mechanism: The set method in KeyValueStoreBackend was modified to include an extra state argument, causing compatibility issues
  • Why the fix works: Restores the KeyValueStoreBackend.set method without the state argument, fixing compatibility issues with other projects. (first fixed release: 4.4.6).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.6 in real deployments (not just unit tests).
  • The set method in KeyValueStoreBackend was modified to include an extra state argument, causing compatibility issues
  • Surfaces as: TypeError: set() takes 3 positional arguments but 4 were given

Proof / Evidence

  • GitHub issue: #6155
  • Fix PR: https://github.com/celery/celery/pull/6173
  • First fixed release: 4.4.6
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.46

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“@robvdl I don't reproduce locally. I would suggest to either running again python setup.py install or to recreate your virtualenv.”
@mchataigner · 2020-06-04 · source
“@mchataigner It looks like @robvdl is using the django-cache results backend which as I understand it is part of the django-celery-results project”
@callorico · 2020-06-08 · source
“I am using Redis as a broker. I thought this info could help too possibly from my Django settings.py and celery.py: We don't really care…”
@robvdl · 2020-06-04 · source
“I use Docker and rebuild all the time. It's fine I will investigate it some time later at work but it might be a while…”
@robvdl · 2020-06-04 · source

Failure Signature (Search String)

  • TypeError: set() takes 3 positional arguments but 4 were given

Error Message

Stack trace
error.txt
Error Message ------------- TypeError: set() takes 3 positional arguments but 4 were given

Minimal Reproduction

repro.py
celery_default_1 | [2020-06-04 19:51:47,723: ERROR/MainProcess] Pool callback raised exception: TypeError('set() takes 3 positional arguments but 4 were given',) celery_default_1 | Traceback (most recent call last): celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/billiard/pool.py", line 1796, in safe_apply_callback celery_default_1 | fun(*args, **kwargs) celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/celery/worker/request.py", line 528, in on_failure celery_default_1 | store_result=self.store_errors, celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/celery/backends/base.py", line 169, in mark_as_failure celery_default_1 | traceback=traceback, request=request) celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/celery/backends/base.py", line 443, in store_result celery_default_1 | request=request, **kwargs) celery_default_1 | File "/usr/share/dashboard/venv/lib/python3.6/site-packages/celery/backends/base.py", line 858, in _store_result celery_default_1 | self.set(self.get_key_for_task(task_id), self.encode(meta), state) celery_default_1 | TypeError: set() takes 3 positional arguments but 4 were given

Environment

  • Python: 3.6

What Broke

Users experienced TypeError exceptions when attempting to store results, leading to task failures.

Why It Broke

The set method in KeyValueStoreBackend was modified to include an extra state argument, causing compatibility issues

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install celery==4.4.6

When NOT to use: This fix should not be applied if the application relies on the state argument for backend operations.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Option D — Guard side-effects with OnceOnly Guardrail for side-effects

Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.

  • Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
  • Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
  • Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
onceonly.py
from onceonly import OnceOnly import os once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True) # Stable idempotency key per real side-effect. # Use a request id / job id / webhook delivery id / Stripe event id, etc. event_id = "evt_..." # replace key = f"stripe:webhook:{event_id}" res = once.check_lock(key=key, ttl=3600) if res.duplicate: return {"status": "already_processed"} # Safe to execute the side-effect exactly once. handle_event(event_id)

See OnceOnly SDK

When NOT to use: Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

Fix reference: https://github.com/celery/celery/pull/6173

First fixed release: 4.4.6

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be applied if the application relies on the state argument for backend operations.
  • Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
  • Pin production dependencies and upgrade only with a reproducible test that hits the failing path.

Version Compatibility Table

VersionStatus
4.4.6 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.