The Fix
pip install celery==5.6.0
Based on closed celery/celery issue #9861 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -1,6 +1,7 @@
from __future__ import annotations
+import logging
import numbers
import os
from zoneinfo import ZoneInfo
from celery.utils.time import LocalTimezone
from celery import Celery
capp = Celery("test_app")
# Case 1: enable_utc=True (default)
capp.conf.enable_utc = True
del capp.timezone
print(capp.timezone) # UTC
assert isinstance(capp.timezone, ZoneInfo)
# Case 2: enable_utc=False and no time_zone configured
capp.conf.enable_utc = False
del capp.timezone
print(capp.timezone) # <LocalTimezone: UTC+02>
assert isinstance(capp.timezone, LocalTimezone) # Problematic
# Case 3: timezone explicitly set to IANA name
capp.conf.timezone = "Pacific/Chatham"
del capp.timezone
print(capp.timezone) # Pacific/Chatham
assert isinstance(capp.timezone, ZoneInfo)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install celery==5.6.0\nWhen NOT to use: Do not use this fix if backward compatibility with LocalTimezone is critical.\n\n
Why This Fix Works in Production
- Trigger: assert isinstance(capp.timezone, ZoneInfo)
- Mechanism: Replaces LocalTimezone with tzlocal.get_localzone() to ensure IANA time zone support in Celery.
- Why the fix works: Replaces LocalTimezone with tzlocal.get_localzone() to ensure IANA time zone support in Celery. (first fixed release: 5.6.0).
- 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
- Production symptom (often without a traceback): assert isinstance(capp.timezone, ZoneInfo)
Proof / Evidence
- GitHub issue: #9861
- Fix PR: https://github.com/celery/celery/pull/9862
- First fixed release: 5.6.0
- 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.53
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Im in favor of it. but we have to be careful about backward compatibility”
Failure Signature (Search String)
- assert isinstance(capp.timezone, ZoneInfo)
- assert isinstance(capp.timezone, LocalTimezone) # Problematic
Copy-friendly signature
Failure Signature
-----------------
assert isinstance(capp.timezone, ZoneInfo)
assert isinstance(capp.timezone, LocalTimezone) # Problematic
Error Message
Signature-only (no traceback captured)
Error Message
-------------
assert isinstance(capp.timezone, ZoneInfo)
assert isinstance(capp.timezone, LocalTimezone) # Problematic
Minimal Reproduction
from zoneinfo import ZoneInfo
from celery.utils.time import LocalTimezone
from celery import Celery
capp = Celery("test_app")
# Case 1: enable_utc=True (default)
capp.conf.enable_utc = True
del capp.timezone
print(capp.timezone) # UTC
assert isinstance(capp.timezone, ZoneInfo)
# Case 2: enable_utc=False and no time_zone configured
capp.conf.enable_utc = False
del capp.timezone
print(capp.timezone) # <LocalTimezone: UTC+02>
assert isinstance(capp.timezone, LocalTimezone) # Problematic
# Case 3: timezone explicitly set to IANA name
capp.conf.timezone = "Pacific/Chatham"
del capp.timezone
print(capp.timezone) # Pacific/Chatham
assert isinstance(capp.timezone, ZoneInfo)
What Broke
Integrations fail due to missing IANA time zone names, causing display issues.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install celery==5.6.0
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)
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)
Fix reference: https://github.com/celery/celery/pull/9862
First fixed release: 5.6.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if backward compatibility with LocalTimezone is critical.
- 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
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
- Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
- Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.
Version Compatibility Table
| Version | Status |
|---|---|
| 5.6.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.