Skip to content

Chord errback set as a single signature is never called; its keys are published as tasks instead #10906

Closed

Description

@avanish-garg

Checklist

  • I have verified that the issue exists against the main branch 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 report in the issue.
    (if you are not able to do this, then at least specify the Celery
    version affected).
  • I have verified that the issue exists against the main branch of Celery.
  • I have included the contents of pip freeze in 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 Python version
    and/or implementation.
  • I have tried reproducing the issue on more than one message broker and/or
    result backend.
  • I have tried reproducing the issue on more than one version of the message
    broker and/or result backend.
  • I have tried reproducing the issue on more than one operating system.
  • I have tried reproducing the issue on more than one workers pool.
  • I have tried reproducing the issue with autoscaling, retries,
    ETA/Countdown & rate limits disabled.
  • I have tried reproducing the issue after downgrading
    and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

Possible Duplicates

  • None

Environment & Settings

Celery version: 5.7.0rc1 (collider), main at 0731c05

celery report Output:

software -> celery:5.7.0rc1 (collider) kombu:5.7.0rc1 py:3.12.14
            billiard:4.3.1 memory:N/A
platform -> system:Darwin arch:64bit
            kernel version:25.3.0 imp:CPython
loader   -> celery.loaders.app.AppLoader
settings -> transport:memory results:cache+memory://

broker_url: 'memory://:********@localhost//'
result_backend: 'cache+memory://'
deprecated_settings: None
task_track_started: False
include: 
    ('celery.app.builtins', 'repro')

Steps to Reproduce

Required Dependencies

  • Minimal Python Version: N/A or Unknown
  • Minimal Celery Version: N/A or Unknown
  • Minimal Kombu Version: N/A or Unknown
  • Minimal Broker Version: N/A or Unknown
  • Minimal Result Backend Version: N/A or Unknown
  • 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.1
billiard==4.3.1
celery @ git+https://github.com/celery/celery@0731c053b0e09f231363ec62988fded6c9846878
click==8.5.0
click-didyoumean==0.3.1
click-plugins==1.1.1.2
click-repl==0.4.1
kombu==5.7.0rc1
prompt-toolkit==3.0.53
python-dateutil==2.9.0.post0
six==1.17.0
typing-extensions==4.16.0
tzdata==2026.4
tzlocal==5.4.4
vine==5.1.0
wcwidth==0.9.2

Other Dependencies

Details

N/A. The in-memory broker and cache backend are enough. The affected code is in the base `Backend` class, so the backend choice should not matter.

Minimally Reproducible Test Case

Details

from celery import Celery, chord
from celery.contrib.testing.worker import start_worker

app = Celery("repro", broker="memory://", backend="cache+memory://")
calls = []


@app.task
def add(x, y):
    return x + y


@app.task
def fail():
    raise ValueError("boom")


@app.task
def tsum(values):
    return sum(values)


@app.task
def on_error(*args, **kwargs):
    calls.append(args)


with start_worker(app, pool="solo", perform_ping_check=False):
    for label, link_error in [("single", on_error.s()), ("list", [on_error.s()])]:
        calls.clear()
        body = tsum.s().set(link_error=link_error)
        result = chord([add.s(1, 1), fail.s()], body).apply_async()
        result.get(timeout=10, propagate=False)
        print(f"{label:6} link_error -> chord state {result.state}, errback called {len(calls)} time(s)")

Expected Behavior

When a header task fails, the chord body's errback is called once whether link_error holds a single signature or a list. The Task.apply_async docstring describes link_error as "A single, or a list of task signatures". Every other place that reads the option wraps it with maybe_list(), for example Signature.stamp_links and _chain.unchain_tasks in canvas.py, and app/task.py.

Actual Behavior

The list form works, but with a single signature the errback is never called:

single link_error -> chord state FAILURE, errback called 0 time(s)
list   link_error -> chord state FAILURE, errback called 1 time(s)

Instead, the worker receives one message per key of the signature dict:

[2026-10-20 01:46:30,036: ERROR/MainProcess] Received unregistered task of type 'task'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?
...
Received unregistered task of type 'args'.
Received unregistered task of type 'kwargs'.
Received unregistered task of type 'options'.
Received unregistered task of type 'subtask_type'.
Received unregistered task of type 'immutable'.

Backend.chord_error_from_stack() (celery/backends/base.py:474) passes callback.options.get("link_error", []) straight to _create_fake_task_request() as the errback list. A Signature is a dict, so _call_task_errbacks() iterates its keys, turns each one into app.signature('task'), app.signature('args') and so on, and sends them as tasks. _handle_group_chord_error() (celery/backends/base.py:518) has the same line, so a group body publishes the six bogus tasks once per body task. chord.link_error() and Signature.on_error() always store a list, so they are unaffected. The bug needs a single signature in the options, e.g. body.set(link_error=eb.s()), signature(..., options={'link_error': eb.s()}) or task.signature(..., link_error=eb.s()).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions