Repository navigation
Description
Checklist
- I have verified that the issue exists against the
mainbranch of Celery. - This has already been asked to the discussions forum first.
- I have read the relevant section in the
contribution guide
on reporting bugs. - I have checked the issues list
for similar or identical bug reports. - I have checked the pull requests list
for existing proposed fixes. - I have checked the commit log
to find out if the bug was already fixed in the main branch. - I have included all related issues and possible duplicate issues
in this issue (If there are none, check this box anyway). - I have tried to reproduce the issue with pytest-celery and added the reproduction script below.
Mandatory Debugging Information
- I have included the output of
celery -A proj reportin the issue. - I have verified that the issue exists against the
mainbranch of Celery. - I have included the contents of
pip freezein the issue. - I have included all the versions of all the external dependencies required
to reproduce this bug.
Optional Debugging Information
-
I have tried reproducing the issue on more than one message broker and/or
result backend.Not with a live broker. Reproduced with the in-memory broker and backend; the failing code path is in
celery/canvas.pyand does not depend on them.
Related Issues and Possible Duplicates
Related Issues
- None
Possible Duplicates
- None
Environment & Settings
Celery version: 5.7.0a1, main @ 508c112
celery report Output:
software -> celery:5.7.0a1 (recovery) kombu:5.7.0a1 py:3.11.15
billiard:4.3.0 memory:N/A
platform -> system:Linux arch:64bit, ELF
kernel version:6.18.44-fc-v64 imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:memory results:cache+memory://
broker_url: 'memory://:********@localhost//'
result_backend: 'cache+memory://'
deprecated_settings: None
Steps to Reproduce
Required Dependencies
- Minimal Python Version: N/A or Unknown
- Minimal Celery Version: N/A or Unknown (reproduced on
main@ 508c112) - Minimal Kombu Version: N/A or Unknown
- Minimal Broker Version: N/A (in-memory broker)
- Minimal Result Backend Version: N/A (
cache+memory://) - Minimal OS and/or Kernel Version: N/A or Unknown
- Minimal Broker Client Version: N/A or Unknown
- Minimal Result Backend Client Version: N/A or Unknown
Python Packages
pip freeze Output:
amqp==5.4.0
billiard==4.3.0
celery @ main (508c112)
click==8.5.0
click-didyoumean==0.3.1
click-plugins==1.1.1.2
click-repl==0.4.0
kombu==5.7.0a1
python-dateutil==2.9.0.post0
tzdata==2026.5
tzlocal==5.4.4
vine==5.1.0
Other Dependencies
Details
N/A
Minimally Reproducible Test Case
Details
from celery import Celery, chain, chord
from celery.contrib.testing.worker import start_worker
app = Celery('repro', broker='memory://', backend='cache+memory://')
@app.task
def add(x, y=0):
return x + y
@app.task
def tsum(xs):
return sum(xs)
@app.task
def cb(result):
print('callback got', result)
# 1. link= on a chord fails on the client
try:
chord([add.s(1, 1), add.s(2, 2)], tsum.s()).apply_async(link=cb.s())
except TypeError as exc:
print('1.', repr(exc))
# 2. A chain ending in a chord, with a callback, fails on the worker
with start_worker(app, pool='solo', perform_ping_check=False, loglevel='CRITICAL'):
res = chain(add.s(1, 1), chord([add.s(10), add.s(20)], tsum.s())).apply_async(link=cb.s())
try:
res.get(timeout=5)
except Exception as exc:
print('2.', repr(exc))
print('2. first task:', res.parent.parent.state, repr(res.parent.parent.result))Expected Behavior
link / link_error given to a chord as options are attached to the chord body, the same as chord.link() / chord.link_error():
chord(...).apply_async(link=cb)runs the chord and callscbwith the chord's result.- The chain runs
add(1, 1), then the chord, and returns34.cbis called once with34.
Actual Behavior
1. TypeError('Cannot add link to group: use a chord')
2. TypeError('Cannot add link to group: use a chord')
2. first task: FAILURE TypeError('Cannot add link to group: use a chord')
In case 2 the client call succeeds, but on the worker add(1, 1) is stored as FAILURE although it returned 2. The chord header is never published and the callback never runs. With task_always_eager both cases work, because chord.apply() does not go through chord.run(), so eager test suites do not catch this.
Cause: _chord.run() copies the merged options to the body (correct), then passes the same options to header.apply_async(). It removes only chain, chord and task_id first, so link / link_error reach the header group, and group.apply_async() always rejects them. For the chain case, _chain.run() stores the chain's link in the options of its last step (the chord), and the worker applies that chord after the first task succeeds.
Activity
docs: reference issue celery#10781 in the changelog entry
test: add integration tests for chord link/link_error options
fix(canvas): give a chord's link/link_error options to its body only (#…