Bug description
We are getting the following exception when the scheduled celery.backend_cleanup's task is processed:
ERROR [celery.beat:284] Message Error: Couldn't apply scheduled task celery.backend_cleanup: backend_cleanup() got an unexpected keyword argument 'async_user'
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/celery/beat.py", line 404, in apply_async
return task.apply_async(entry_args, entry_kwargs,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/dojo/celery.py", line 74, in apply_async
return super().apply_async(args=args, kwargs=kwargs, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/celery/app/task.py", line 573, in apply_async
check_arguments(*(args or ()), **(kwargs or {}))
TypeError: backend_cleanup() got an unexpected keyword argument 'async_user'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/celery/beat.py", line 282, in apply_entry
result = self.apply_async(entry, producer=producer, advance=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/celery/beat.py", line 412, in apply_async
reraise(SchedulingError, SchedulingError(
File "/usr/local/lib/python3.12/site-packages/celery/exceptions.py", line 109, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.12/site-packages/celery/beat.py", line 404, in apply_async
return task.apply_async(entry_args, entry_kwargs,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/dojo/celery.py", line 74, in apply_async
return super().apply_async(args=args, kwargs=kwargs, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/celery/app/task.py", line 573, in apply_async
check_arguments(*(args or ()), **(kwargs or {}))
celery.beat.SchedulingError: Couldn't apply scheduled task celery.backend_cleanup: backend_cleanup() got an unexpected keyword argument 'async_user'
As far as I know, the celery.backend_cleanup is a default celery task that is executed daily at 04:00 AM to remove expired tasks results.
Reviewing the code, the reason of the issue seems to be the inclusion of the async_user parameter to all the DefectDojo async tasks here, which is executed too for default celery tasks like celery.backend_cleanup
Steps to reproduce
Steps to reproduce the behavior:
- Deploy DefectDojo
- Access the
celerybeat pod
- Run
python3 manage.py shell
- Run the following Python code to trigger the
celery.backend_cleanup asynchronously
from dojo.celery import app
app.tasks['celery.backend_cleanup'].apply_async()
Result:
Alternative:
- Check the 04:00 AM logs
Expected behavior
The celery.backend_cleanup task is executed successfully.
Deployment method (select with an X)
Environment information
- Operating System: MacOS Tahoe 26.2
- Docker Compose version 5.1.0
- DefectDojo version (see footer) or commit message: 2.56.2
Additional context (optional)
I will open a pull request to contribute the fix soon
Bug description
We are getting the following exception when the scheduled celery.backend_cleanup's task is processed:
As far as I know, the celery.backend_cleanup is a default celery task that is executed daily at 04:00 AM to remove expired tasks results.
Reviewing the code, the reason of the issue seems to be the inclusion of the
async_userparameter to all the DefectDojo async tasks here, which is executed too for default celery tasks likecelery.backend_cleanupSteps to reproduce
Steps to reproduce the behavior:
celerybeatpodpython3 manage.py shellcelery.backend_cleanupasynchronouslyResult:
Alternative:
Expected behavior
The
celery.backend_cleanuptask is executed successfully.Deployment method (select with an
X)Environment information
Additional context (optional)
I will open a pull request to contribute the fix soon