diff --git a/api/tasks/delete_account_task.py b/api/tasks/delete_account_task.py index fa7a0ce0bff6ab..d005e1178f9eb7 100644 --- a/api/tasks/delete_account_task.py +++ b/api/tasks/delete_account_task.py @@ -12,13 +12,13 @@ @shared_task(queue="dataset") def delete_account_task(account_id, reason: str): + account = db.session.query(Account).filter(Account.id == account_id).first() try: BillingService.delete_account(account_id, reason) except Exception as e: logger.exception(f"Failed to delete account {account_id} from billing service.") raise - account = db.session.query(Account).filter(Account.id == account_id).first() if not account: logger.error(f"Account {account_id} not found.") return