Skip to content

Fix test_database AttributeError on ignore_result with Celery 5.x - #510

Merged
auvipy merged 1 commit into
celery:mainfrom
obbardc:wip/obbardc/fix-tests
Jun 22, 2026
Merged

Fix test_database AttributeError on ignore_result with Celery 5.x#510
auvipy merged 1 commit into
celery:mainfrom
obbardc:wip/obbardc/fix-tests

Conversation

@obbardc

@obbardc obbardc commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

The protocol 1 test requests are built via hybrid_to_proto2() which does not include 'ignore_result' in the message headers. Celery 5.x's Request.init reads 'ignore_result' from the headers and, when absent, falls back to self._task.ignore_result. Since these tests pass the task name rather than a task object, it causes an error:

AttributeError: 'str' object has no attribute 'ignore_result'

Set the 'ignore_result' header to False in _create_request() so the fallback is never use. This is a no-op for protocol 2 (which already sets the header) and keeps request.task as the 'my_task' string, preserving the existing task_name assertions.

Closes: #508

The protocol 1 test requests are built via hybrid_to_proto2() which does
not include 'ignore_result' in the message headers. Celery 5.x's
Request.__init__ reads 'ignore_result' from the headers and, when absent,
falls back to self._task.ignore_result. Since these tests pass the task
name rather than a task object, it causes an error:

    AttributeError: 'str' object has no attribute 'ignore_result'

Set the 'ignore_result' header to False in _create_request() so the
fallback is never use. This is a no-op for protocol 2 (which already sets
the header) and keeps request.task as the 'my_task' string, preserving
the existing task_name assertions.

Closes: celery#508
Signed-off-by: Christopher Obbard <obbardc@debian.org>
@auvipy
auvipy merged commit 067dfc9 into celery:main Jun 22, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests fail with Celery 5.6.3

2 participants