Skip to content

Commit

Permalink
chore: When trimming email addresses ignore failures when removing an…
Browse files Browse the repository at this point in the history
… email address multiple times.
  • Loading branch information
macdiesel committed Nov 27, 2023
1 parent fccf0c3 commit 4bcdea6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion license_manager/apps/api/v1/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from collections import OrderedDict
from contextlib import suppress
from uuid import uuid4

from celery import chain
Expand Down Expand Up @@ -654,7 +655,9 @@ 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())
# Ignore error if email was already removed from the list e.g. email has multiple licenses assigned
with suppress(ValueError):
trimmed_emails.remove(email.lower())

return trimmed_emails, already_associated_emails

Expand Down

0 comments on commit 4bcdea6

Please sign in to comment.