Skip to content

Commit

Permalink
Fixed bug where chord.link_error() throws an exception on a dict type…
Browse files Browse the repository at this point in the history
… errback object (#8702)

* Fixed bug where _chord.link_error() would call clone() on a dict instead of a signature

* Added unit test: test_flag_allow_error_cb_on_chord_header_with_dict_callback()
  • Loading branch information
Nusnus committed Dec 7, 2023
1 parent 17631f7 commit 6701bd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions celery/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,8 @@ def link_error(self, errback):
``False`` (the current default), then the error callback will only be
applied to the body.
"""
errback = maybe_signature(errback)

if self.app.conf.task_allow_error_cb_on_chord_header:
for task in maybe_list(self.tasks) or []:
task.link_error(errback.clone(immutable=True))
Expand Down
8 changes: 8 additions & 0 deletions t/unit/tasks/test_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,14 @@ def test_flag_allow_error_cb_on_chord_header_various_header_types(self):
errback = c.link_error(sig)
assert errback == sig

@pytest.mark.usefixtures('depends_on_current_app')
def test_flag_allow_error_cb_on_chord_header_with_dict_callback(self):
self.app.conf.task_allow_error_cb_on_chord_header = True
c = chord(group(signature('th1'), signature('th2')), signature('tbody'))
errback_dict = dict(signature('tcb'))
errback = c.link_error(errback_dict)
assert errback == errback_dict

def test_chord__or__group_of_single_task(self):
""" Test chaining a chord to a group of a single task. """
c = chord([signature('header')], signature('body'))
Expand Down

0 comments on commit 6701bd5

Please sign in to comment.