Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: import_alums fails when there is more than one user with the same email address #1210

Open
pdpinch opened this issue Apr 16, 2021 · 1 comment

Comments

@pdpinch
Copy link
Member

pdpinch commented Apr 16, 2021

I'm not sure how this happens in production, but we have multiple user accounts with the same email address.

In these cases, the import_alums management command fails with this traceback:

Traceback (most recent call last):
  File "/app/profiles/api.py", line 397, in import_alumni
    import_alum(alum)
  File "/app/profiles/api.py", line 299, in import_alum
    user = User.objects.get(email__iexact=alum.learner_email)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 412, in get
    (self.model._meta.object_name, num)
django.contrib.auth.models.MultipleObjectsReturned: get() returned more than one User -- it returned 3!

When there is more than once account with the same email, we could chose the one that has been logged in to most recently.

@mbertrand
Copy link
Member

Looks like there are lots of users with dupe email accounts on prod (536 dupe emails), in the worst case 6 Users with the same email (but only 1 of those ever logged in).

This complicates hubspot api syncing, and specifically tracking the hubspot id associated with each contact.

Hubspot only allows 1 contact per email, so users with dupe emails would all be associated with the same hubspot id, but that will lead to an integrity error in our database (only 1 contact per hubspot id allowed).

Not sure if I should remove that integrity constraint or fix the underlying issue causing dupe emails and remove the users that never logged in. Of the 536 dupes, there are only 4 where >1 User logged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants