From 9665def3bdc759a1fd391aed4c5cd82433191ef9 Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Tue, 31 Jan 2023 08:54:26 +0100 Subject: [PATCH] error-reporting: fix setting call_context on dummy-request available in sentry --- rhodecode/lib/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py index 19f169b7..703877bf 100644 --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -460,7 +460,12 @@ def attach_context_attributes(context, request, user_id=None, is_api=None): context.rhodecode_user = request.rpc_user # attach the whole call context to the request - request.call_context = context + # use set_call_context method if request has it + # sometimes in Celery context requests is "different" + if hasattr(request, 'set_call_context'): + request.set_call_context(context) + else: + request.call_context = context def get_auth_user(request): @@ -616,6 +621,9 @@ def bootstrap_request(**kwargs): def call_context(self): return self._call_context + def set_call_context(self, new_context): + self._call_context = new_context + class TestDummySession(pyramid.testing.DummySession): def save(*arg, **kw): pass