From 469362214ba24326f543d772ead530b052a96c64 Mon Sep 17 00:00:00 2001 From: Troy Sankey Date: Mon, 29 Jul 2024 11:24:31 -0700 Subject: [PATCH] fix: Don't throw an exception if no pending licenses were found It seems plausible to me that this would occasionally happen as part of the normal flow of things, so instead of alerting on-call just log a warning. --- license_manager/apps/api/tasks.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/license_manager/apps/api/tasks.py b/license_manager/apps/api/tasks.py index bc1bde3c..1a491797 100644 --- a/license_manager/apps/api/tasks.py +++ b/license_manager/apps/api/tasks.py @@ -166,6 +166,12 @@ def _batch_notify_or_remind_assigned_emails( if len(pending_licenses) > allowed_batch_size: raise Exception(f'Found more than {allowed_batch_size} licenses, no email sent to {action_type}') + if len(pending_licenses) == 0: + logger.warning( + f'{LICENSE_DEBUG_PREFIX} No pending licenses found for given emails, no email sent to {action_type}.' + ) + return pending_licenses + enterprise_api_client = EnterpriseApiClient() enterprise_customer = enterprise_api_client.get_enterprise_customer_data( subscription_plan.enterprise_customer_uuid,