From 1fa7985b01634c662f02f81d1f8b0ab1216538a4 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Sun, 14 Sep 2025 01:37:03 -0300 Subject: [PATCH] fix(rules:dry-run): current_user getting overwritten and delete on synchronous call --- app/apps/rules/tasks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/apps/rules/tasks.py b/app/apps/rules/tasks.py index a75b217..79e2478 100644 --- a/app/apps/rules/tasks.py +++ b/app/apps/rules/tasks.py @@ -536,7 +536,8 @@ def check_for_transaction_rules( return transaction user = get_user_model().objects.get(id=user_id) - write_current_user(user) + if not dry_run: + write_current_user(user) logs = [] if dry_run else None dry_run_results = DryRunResults(dry_run=dry_run) @@ -761,11 +762,12 @@ def check_for_transaction_rules( "** Error while executing 'check_for_transaction_rules' task", level="error", ) - delete_current_user() if not dry_run: + delete_current_user() raise e - delete_current_user() + if not dry_run: + delete_current_user() return logs, dry_run_results.results