The Fix
pip install celery==5.6.0
Based on closed celery/celery issue #6792 · PR/commit linked
@@ -2234,7 +2234,8 @@ def run(self, header, body, partial_args, app=None, interval=None,
body.options.update(options)
- bodyres = body.freeze(task_id, root_id=root_id)
+ body_task_id = task_id or uuid()
+ bodyres = body.freeze(body_task_id, group_id=group_id, root_id=root_id)
import celery
from celery.app.task import Task
from celery import shared_task
@shared_task(base=Task)
def echo_task(taskdata):
return taskdata
@shared_task(base=Task)
def error_task(taskdata):
1/0
return taskdata
exec_list = [error_task.s(), echo_task.s()]
x = celery.chord(exec_list, echo_task.s())
y = celery.chain([x, echo_task.s()])
result = y(None).get()
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: This fix is not applicable if the task ID is intentionally set to None.\n\n
Why This Fix Works in Production
- Trigger: Exception raised outside body: TypeError('sequence item 1: expected a bytes-like object, NoneType found',):
- Mechanism: The task ID could be None when using a chain as the body of a chord
- Why the fix works: Fixes an issue where the task ID could be None when using a chain as the body of a chord, causing errors during error handling. (first fixed release: 5.6.0).
Why This Breaks in Prod
- Shows up under Python 3.6 in real deployments (not just unit tests).
- The task ID could be None when using a chain as the body of a chord
- Surfaces as: Exception raised outside body: TypeError('sequence item 1: expected a bytes-like object, NoneType found',):
Proof / Evidence
- GitHub issue: #6792
- Fix PR: https://github.com/celery/celery/pull/9774
- First fixed release: 5.6.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.19
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“> Are you saying it still reproduces? @DavraYoung can you check if it reproduces with the current main please? @Nusnus yes, it still reproduces with…”
“Yep I'm getting the same problem also. Trying to use a chord with a group of tasks with a call back and also a custom…”
“This should have solved by https://github.com/celery/celery/pull/9774”
“Hey @aditya051293 :wave:, Thank you for opening an issue”
Failure Signature (Search String)
- Exception raised outside body: TypeError('sequence item 1: expected a bytes-like object, NoneType found',):
Error Message
Stack trace
Error Message
-------------
Exception raised outside body: TypeError('sequence item 1: expected a bytes-like object, NoneType found',):
Traceback (most recent call last):
File "/home/aditya/local/venv/lib/python3.6/site-packages/celery/backends/redis.py", line 519, in on_chord_part_return
resl = [unpack(tup, decode) for tup in resl]
File "/home/aditya/local/venv/lib/python3.6/site-packages/celery/backends/redis.py", line 519, in <listcomp>
resl = [unpack(tup, decode) for tup in resl]
File "/home/aditya/local/venv/lib/python3.6/site-packages/celery/backends/redis.py", line 425, in _unpack_chord_result
raise ChordError(f'Dependency {tid} raised {retval!r}')
celery.exceptions.ChordError: Dependency b07a3b72-89c8-4c6b-9d7b-be24cda9af61 raised TaskException('ZeroDivisionError: division by zero',)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/aditya/local/venv/lib/python3.6/site-packages/celery/app/trace.py", line 518, in trace_task
uuid, retval, task_request, publish_result,
File "/home/aditya/local/venv/lib/python3.6/site-packages/celery/backends/base.py", line 163, in mark_as_done
self.on_chord_part_return(request, state, result)
File "/home/aditya/local/venv/lib/python3.6/site-packages/celery/backends/redis.py", line 538, in on_chord_part_return
return self.chord_error_from_stack(callback, exc)
File
... (truncated) ...
Stack trace
Error Message
-------------
[2022-02-11 10:44:23,017: ERROR/ForkPoolWorker-10] Task core.engine.tasks.rule.run_rule[a2123704-bbc4-47f1-8ca4-9d0734d57c80] raised unexpected: TypeError('sequence item 1: expected a bytes-like object, NoneType found') Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/miniscanner--a4Dn15j-py3.8/lib/python3.8/site-packages/celery/app/trace.py", line 451, in trace_task
R = retval = fun(*args, **kwargs)
File "/root/.cache/pypoetry/virtualenvs/miniscanner--a4Dn15j-py3.8/lib/python3.8/site-packages/celery/app/trace.py", line 734, in __protected_call__
return self.run(*args, **kwargs)
File "/data/sourcecode/miniscanner/core/engine/tasks/rule.py", line 54, in run_rule scanner.verify()
File "<string>", line 51, in verify
KeyError: 'sad'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/miniscanner--a4Dn15j-py3.8/lib/python3.8/site-packages/celery/backends/redis.py", line 520, in on_chord_part_return resl = [unpack(tup, decode) for tup in resl]
File "/root/.cache/pypoetry/virtualenvs/miniscanner--a4Dn15j-py3.8/lib
... (truncated) ...
Stack trace
Error Message
-------------
[2024-08-19 09:20:22,043: ERROR/ForkPoolWorker-5] Task assistant.tasks.channels_generation[e5b492ec-ca00-40ec-911f-b5917205d009] raised unexpected: ValueError('task_id must not be empty. Got None instead.')
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/celery/backends/redis.py", line 528, in on_chord_part_return
resl = [unpack(tup, decode) for tup in resl]
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/celery/backends/redis.py", line 434, in _unpack_chord_result
raise ChordError(f'Dependency {tid} raised {retval!r}')
celery.exceptions.ChordError: Dependency 0163a4bc-da03-48f3-99eb-acabc9e0a0a8 raised AttributeError("'NoneType' object has no attribute 'group'")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 520, in trace_task
task.backend.mark_as_done(
File "/usr/local/lib/python3.12/site-packages/celery/backends/base.py", line 159, in mark_as_done
self.on_chord_part_return(request, state, result)
File "/usr/local/lib/python3.12/site-packages/celery/backends/redis.py", line 547, in on_chord_part_return
return self.chord_error_from_stack(callback, exc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/s
... (truncated) ...
Minimal Reproduction
import celery
from celery.app.task import Task
from celery import shared_task
@shared_task(base=Task)
def echo_task(taskdata):
return taskdata
@shared_task(base=Task)
def error_task(taskdata):
1/0
return taskdata
exec_list = [error_task.s(), echo_task.s()]
x = celery.chord(exec_list, echo_task.s())
y = celery.chain([x, echo_task.s()])
result = y(None).get()
Environment
- Python: 3.6
What Broke
Errors occurred during error handling, leading to unexpected exceptions.
Why It Broke
The task ID could be None when using a chain as the body of a chord
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.
Fix reference: https://github.com/celery/celery/pull/9774
First fixed release: 5.6.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the task ID is intentionally set to None.
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
- 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
| 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.