Jump to solution
Verify

The Fix

pip install celery==5.3.0rc1

Based on closed celery/celery issue #8128 · 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
@@ -738,6 +738,9 @@ def send_task(self, name, args=None, kwargs=None, countdown=None, expires_s = (maybe_make_aware( expires) - self.now()).total_seconds() + elif isinstance(expires, str): + expires_s = (maybe_make_aware( + datetime.fromisoformat(expires)) - self.now()).total_seconds()
repro.py
aliyun-python-sdk-core==2.13.36 aliyun-python-sdk-core-v3==2.13.33 aliyun-python-sdk-kms==2.16.0 amqp==5.1.1 asgiref==3.6.0 asyncio-gevent==0.2.1 attrs==22.2.0 billiard==3.6.4.0 boto3==1.24.59 boto3-stubs==1.26.90 botocore==1.27.91 botocore-stubs==1.29.90 celery==5.2.7 certifi==2022.12.7 cffi==1.15.1 chardet==4.0.0 click==8.1.3 click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.2.0 crcmod==1.7 cryptography==39.0.1 ddt==1.6.0 defusedxml==0.7.1 diff-match-patch==20200713 distlib==0.3.6 Django==3.2.18 django-celery-beat==2.2.0 django-cors-headers==3.14.0 django-cprofile-middleware==1.0.5 django-elasticsearch-dsl==7.2.2 django-filter==22.1 django-import-export==2.5.0 django-mock-queries==2.1.7 django-modeltranslation==0.17.7 django-ranged-response==0.2.0 django-redis==5.2.0 django-rest-framework-proxy==1.6.0 django-simple-captcha==0.5.17 django-stubs==1.15.0 django-stubs-ext==0.7.0 django-timezone-field==4.2.3 django-utils==0.0.2 django-utils-six==2.0 django-xff==1.3.0 djangorestframework==3.12.4 djangorestframework-stubs==1.9.1 docxcompose==1.3.4 docxtpl==0.16.0 drf-spectacular==0.22.1 elasticsearch==7.17.7 elasticsearch-dsl==7.4.1 et-xmlfile==1.1.0 filelock==3.10.0 gevent==21.12.0 greenlet==1.1.3.post0 id-validator==1.0.20 idna==2.10 inflection==0.5.1 Jinja2==3.1.2 jmespath==0.10.0 jq==1.3.0 jsonlog==4.0.0 jsonschema==4.17.0 kombu==5.2.4 lxml==4.9.1 MarkupPy==1.14 MarkupSafe==2.1.2 mock==5.0.1 model-bakery==1.10.1 mypy==1.0.1 mypy-extensions==1.0.0 mysqlclient==2.1.1 numpy==1.24.2 odfpy==1.4.1 openpyxl==3.0.9 oss2==2.13.1 packaging==21.3 pep8==1.7.1 Pillow==9.3.0 pipenv==2023.2.18 platformdirs==3.1.1 prompt-toolkit==3.0.38 pycparser==2.21 pycryptodome==3.17 pycryptodomex==3.14.1 PyMySQL==1.0.2 pyparsing==3.0.9 pyre2==0.3.6 pyrsistent==0.19.1 python-crontab==2.7.1 python-dateutil==2.8.2 python-docx==0.8.11 python-json-logger==2.0.7 pytz==2022.6 PyYAML==6.0 redis==3.5.3 requests==2.25.1 result==0.8.0 s3transfer==0.6.0 simhash==2.1.2 six==1.15.0 sqlparse==0.4.3 tablib==3.3.0 tomli==2.0.1 types-awscrt==0.16.12 types-PyMySQL==1.0.19.5 types-pyOpenSSL==23.0.0.4 types-pytz==2022.7.1.2 types-PyYAML==6.0.12.8 ... (truncated) ...
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==5.3.0rc1\nWhen NOT to use: Do not use this fix if expiration dates are always integers.\n\n

Why This Fix Works in Production

  • Trigger: celery.exceptions.Reject: (TypeError("'<' not supported between instances of 'str' and 'int'"), False)
  • Mechanism: TypeError occurs when comparing string and integer types in expiration date handling
  • Why the fix works: Adds support for parsing expiration dates as strings in the send_task method, addressing a TypeError when comparing string and integer types. (first fixed release: 5.3.0rc1).
Production impact:
  • If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).

Why This Breaks in Prod

  • Shows up under Python 3.10 in real deployments (not just unit tests).
  • TypeError occurs when comparing string and integer types in expiration date handling
  • Surfaces as: Traceback (most recent call last):\n File "/opt/dongtai/dongtai_engine/tasks.py", line 242, in search_vul_from_method_pool\n raise RetryableException(f'漏洞检测方法池 {method_pool_sign}…

Proof / Evidence

  • GitHub issue: #8128
  • Fix PR: https://github.com/celery/celery/pull/8134
  • First fixed release: 5.3.0rc1
  • 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.31

Discussion

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

“Hey @Bidaya0 :wave:, Thank you for opening an issue”
@open-collective-bot · 2023-03-16 · source
“you are welcome to send any contribution to fix it”
@auvipy · 2023-03-16 · source

Failure Signature (Search String)

  • celery.exceptions.Reject: (TypeError("'<' not supported between instances of 'str' and 'int'"), False)

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last):\n File "/opt/dongtai/dongtai_engine/tasks.py", line 242, in search_vul_from_method_pool\n raise RetryableException(f'漏洞检测方法池 {method_pool_sign} 不存在,重试第 {tries} 次')
Stack trace
error.txt
Error Message ------------- Traceback (most recent call last):\n File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 734, in retry\n S.apply_async()\n File "/usr/local/lib/python3.10/site-packages/celery/canvas.py", line 219, in apply_async\n return _apply(args, kwargs, **options)\n File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 575, in apply_async\n return app.send_task(\n File "/usr/local/lib/python3.10/site-packages/celery/app/base.py", line 744, in send_task\n if expires_s < 0:
Stack trace
error.txt
Error Message ------------- Traceback (most recent call last):\n File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 451, in trace_task\n R = retval = fun(*args, **kwargs)\n File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 734, in __protected_call__\n return self.run(*args, **kwargs)\n File "/opt/dongtai/dongtai_engine/tasks.py", line 272, in search_vul_from_method_pool\n self.retry(exc=e, countdown=delay)\n File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 736, in retry\n raise Reject(exc, requeue=False)

Minimal Reproduction

repro.py
aliyun-python-sdk-core==2.13.36 aliyun-python-sdk-core-v3==2.13.33 aliyun-python-sdk-kms==2.16.0 amqp==5.1.1 asgiref==3.6.0 asyncio-gevent==0.2.1 attrs==22.2.0 billiard==3.6.4.0 boto3==1.24.59 boto3-stubs==1.26.90 botocore==1.27.91 botocore-stubs==1.29.90 celery==5.2.7 certifi==2022.12.7 cffi==1.15.1 chardet==4.0.0 click==8.1.3 click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.2.0 crcmod==1.7 cryptography==39.0.1 ddt==1.6.0 defusedxml==0.7.1 diff-match-patch==20200713 distlib==0.3.6 Django==3.2.18 django-celery-beat==2.2.0 django-cors-headers==3.14.0 django-cprofile-middleware==1.0.5 django-elasticsearch-dsl==7.2.2 django-filter==22.1 django-import-export==2.5.0 django-mock-queries==2.1.7 django-modeltranslation==0.17.7 django-ranged-response==0.2.0 django-redis==5.2.0 django-rest-framework-proxy==1.6.0 django-simple-captcha==0.5.17 django-stubs==1.15.0 django-stubs-ext==0.7.0 django-timezone-field==4.2.3 django-utils==0.0.2 django-utils-six==2.0 django-xff==1.3.0 djangorestframework==3.12.4 djangorestframework-stubs==1.9.1 docxcompose==1.3.4 docxtpl==0.16.0 drf-spectacular==0.22.1 elasticsearch==7.17.7 elasticsearch-dsl==7.4.1 et-xmlfile==1.1.0 filelock==3.10.0 gevent==21.12.0 greenlet==1.1.3.post0 id-validator==1.0.20 idna==2.10 inflection==0.5.1 Jinja2==3.1.2 jmespath==0.10.0 jq==1.3.0 jsonlog==4.0.0 jsonschema==4.17.0 kombu==5.2.4 lxml==4.9.1 MarkupPy==1.14 MarkupSafe==2.1.2 mock==5.0.1 model-bakery==1.10.1 mypy==1.0.1 mypy-extensions==1.0.0 mysqlclient==2.1.1 numpy==1.24.2 odfpy==1.4.1 openpyxl==3.0.9 oss2==2.13.1 packaging==21.3 pep8==1.7.1 Pillow==9.3.0 pipenv==2023.2.18 platformdirs==3.1.1 prompt-toolkit==3.0.38 pycparser==2.21 pycryptodome==3.17 pycryptodomex==3.14.1 PyMySQL==1.0.2 pyparsing==3.0.9 pyre2==0.3.6 pyrsistent==0.19.1 python-crontab==2.7.1 python-dateutil==2.8.2 python-docx==0.8.11 python-json-logger==2.0.7 pytz==2022.6 PyYAML==6.0 redis==3.5.3 requests==2.25.1 result==0.8.0 s3transfer==0.6.0 simhash==2.1.2 six==1.15.0 sqlparse==0.4.3 tablib==3.3.0 tomli==2.0.1 types-awscrt==0.16.12 types-PyMySQL==1.0.19.5 types-pyOpenSSL==23.0.0.4 types-pytz==2022.7.1.2 types-PyYAML==6.0.12.8 ... (truncated) ...

Environment

  • Python: 3.10

What Broke

Tasks fail to execute due to TypeError, causing potential message loss.

Why It Broke

TypeError occurs when comparing string and integer types in expiration date handling

Fix Options (Details)

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

pip install celery==5.3.0rc1

When NOT to use: Do not use this fix if expiration dates are always integers.

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.
  • This does NOT fix data corruption; it only prevents duplicate side-effects.
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/8134

First fixed release: 5.3.0rc1

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

  • Do not use this fix if expiration dates are always integers.
  • 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
5.3.0rc1 Fixed

Related Issues

No related fixes found.

Sources

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