Logging in after changing email on Blender ID, with new account that has the old email address, causes error #82258

Open
opened 2020-10-30 16:32:37 +01:00 by Sybren A. Stüvel · 2 comments

Short description of Error:

I had a user account on the Conference website, created by logging in with my Blender ID sybren@s....eu. After that, I changed my email address on Blender ID to sybren@blender.org and created a new Blender ID for sybren@s....eu. Now, logging in on the Conference site with my new Blender ID causes a 500 Internal Server Error.

This is caused by the new Blender ID using an already-existing email address. Because the local user cannot be found by Blender ID (it's the first time I log in there), it tries to do a lookup by email address. That finds my already-existing account, because my change in email address wasn't updated on the Conference site. Trying to associate this with the new Blender ID fails, because the association with the old Blender ID account already exists.

Traceback:

Traceback (most recent call last):
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/blender_id_oauth_client/views.py", line 126, in callback_view
    user_info = models.OAuthUserInfo.objects.get(oauth_user_id=oauth_user_id)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 408, in get
    self.model._meta.object_name
blender_id_oauth_client.models.OAuthUserInfo.DoesNotExist: OAuthUserInfo matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "blender_id_oauth_client_oauthuserinfo_pkey"
DETAIL:  Key (user_id)=(14) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/blender_id_oauth_client/views.py", line 135, in callback_view
    models.OAuthUserInfo.objects.create(user=user, oauth_user_id=oauth_user_id)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 422, in create
    obj.save(force_insert=True, using=self.db)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 741, in save
    force_update=force_update, update_fields=update_fields)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 779, in save_base
    force_update, using, update_fields,
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 870, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 908, in _do_insert
    using=using, raw=raw)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 1186, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1335, in execute_sql
    cursor.execute(sql, params)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "blender_id_oauth_client_oauthuserinfo_pkey"
DETAIL:  Key (user_id)=(14) already exists.
**Short description of Error:** I had a user account on the Conference website, created by logging in with my Blender ID `sybren@s....eu`. After that, I changed my email address on Blender ID to `sybren@blender.org` and created a new Blender ID for `sybren@s....eu`. Now, logging in on the Conference site with my new Blender ID causes a 500 Internal Server Error. This is caused by the new Blender ID using an already-existing email address. Because the local user cannot be found by Blender ID (it's the first time I log in there), it tries to do a lookup by email address. That finds my already-existing account, because my change in email address wasn't updated on the Conference site. Trying to associate this with the new Blender ID fails, because the association with the old Blender ID account already exists. **Traceback:** ``` Traceback (most recent call last): File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/blender_id_oauth_client/views.py", line 126, in callback_view user_info = models.OAuthUserInfo.objects.get(oauth_user_id=oauth_user_id) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 408, in get self.model._meta.object_name blender_id_oauth_client.models.OAuthUserInfo.DoesNotExist: OAuthUserInfo matching query does not exist. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "blender_id_oauth_client_oauthuserinfo_pkey" DETAIL: Key (user_id)=(14) already exists. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python3.6/contextlib.py", line 52, in inner return func(*args, **kwds) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/blender_id_oauth_client/views.py", line 135, in callback_view models.OAuthUserInfo.objects.create(user=user, oauth_user_id=oauth_user_id) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 422, in create obj.save(force_insert=True, using=self.db) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 741, in save force_update=force_update, update_fields=update_fields) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 779, in save_base force_update, using, update_fields, File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 870, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 908, in _do_insert using=using, raw=raw) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 1186, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1335, in execute_sql cursor.execute(sql, params) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers return executor(sql, params, many, context) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/var/www/blender-conference/.venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) django.db.utils.IntegrityError: duplicate key value violates unique constraint "blender_id_oauth_client_oauthuserinfo_pkey" DETAIL: Key (user_id)=(14) already exists. ```
Author
Owner

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren
Sybren A. Stüvel changed title from Logging in after changing email on Blender ID causes error to Logging in after changing email on Blender ID, with new account that has the old email address, causes error 2020-10-30 16:50:13 +01:00
Author
Owner

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/conference-website#82258
No description provided.