Skip to content

Commit ee5f04b

Browse files
authored
Exclude async_user from celery task (#14506)
1 parent 3dff3e7 commit ee5f04b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

dojo/celery.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ def apply_async(self, args=None, kwargs=None, **options):
5656
if kwargs is None:
5757
kwargs = {}
5858

59-
# Inject user context if not already present
60-
if "async_user" not in kwargs:
59+
# Inject user context for Dojo tasks only. Celery built-in tasks (e.g.
60+
# celery.backend_cleanup) do not accept custom kwargs.
61+
task_name = self.name or ""
62+
if not task_name.startswith("celery.") and "async_user" not in kwargs:
6163
kwargs["async_user"] = get_current_user()
6264

6365
# Control flag used for sync/async decision; never pass into the task itself

0 commit comments

Comments
 (0)