From 1efa236e0baf5532494341b3b221e01fd4dfa911 Mon Sep 17 00:00:00 2001 From: Brian Beggs Date: Mon, 27 Nov 2023 11:01:08 -0500 Subject: [PATCH] chore: When trimming associated email addresses ignore failures when attempting to remove an email address multiple times. --- license_manager/apps/api/v1/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/license_manager/apps/api/v1/views.py b/license_manager/apps/api/v1/views.py index 8c90f93d..507fc810 100644 --- a/license_manager/apps/api/v1/views.py +++ b/license_manager/apps/api/v1/views.py @@ -1,5 +1,6 @@ import logging from collections import OrderedDict +from contextlib import suppress from uuid import uuid4 from celery import chain @@ -654,7 +655,8 @@ def _trim_already_associated_emails(self, subscription_plan, user_emails): already_associated_licenses.values_list('user_email', flat=True) ) for email in already_associated_emails: - trimmed_emails.remove(email.lower()) + with suppress(ValueError): + trimmed_emails.remove(email.lower()) return trimmed_emails, already_associated_emails