Duplicate entry after SSO login


I got an error in pro 7.1.14 related to SAML provisionning

A user logs into SSO for the first time, the admin needs to activate the account

The admin does not activate the account

The user logs a second time, the account is still unactivated

Then the admin do activate the account

The user tries to log for the third time : he is authorized but the server crashes with this log

Traceback (most recent call last):
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/core/handlers/base.py", line 244, in _legacy_get_response
    response = middleware_method(request)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/shibboleth/middleware.py", line 99, in process_request
    self.make_profile(user, shib_meta)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/shibboleth/middleware.py", line 166, in make_profile
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/models/base.py", line 808, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/models/base.py", line 838, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/models/base.py", line 924, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/models/base.py", line 963, in _do_insert
    using=using, raw=raw)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/models/query.py", line 1079, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/models/sql/compiler.py", line 1112, in execute_sql
    cursor.execute(sql, params)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/django/db/backends/mysql/base.py", line 101, in execute
    return self.cursor.execute(query, args)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/pymysql/cursors.py", line 328, in _query
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/pymysql/connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/pymysql/connections.py", line 732, in _read_query_result
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/pymysql/connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/pymysql/connections.py", line 684, in _read_packet
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/pymysql/protocol.py", line 220, in check_error
  File "/home/cc/seafile/seafile-pro-server-7.1.4/seahub/thirdpart/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
django.db.utils.IntegrityError: (1062, "Duplicate entry 'gauburtin@domain.fr' for key 'profile_profile_contact_email_0975e4bf_uniq'")

What can i do to delete the duplicate wihout deletting the user ?

I’m on a test server, i can delete the user but i would like to know how to only delete the duplicate.

I’m quite sure of the scenario, but the duplicate may have another cause.



I finally deleted the user and restarted SSO login followed by admin activation

On second SSO, the error is traced



"2690"	"profile_profile_contact_email_0975e4bf_uniq"	"1159"	"2"	"1"	"6"	"1142"	"50"


"def"	"seahub_db"	"profile_profile_contact_email_0975e4bf_uniq"	"def"	"seahub_db"	"profile_profile"	"contact_email"	"1"	\N	\N	\N	\N

The issue is only related to SSO (SAML) login.

With Seafile login, it does not occur.

Upgrading to seafile pro 7.1.5 has no effect.

mysqlcheck -u root -p --all-databases --auto-repair has no effect neither

@daniel.pan @Jonathan

Any idea ?



When user login via SAML, Seafile will create/update user’s contact email record in database.

As the contact_email field must be unique in profile_profile table, can you see if there is already a same contact_email record in database ?

1 Like


You were right. I can’t explain why but antother user had the same ‘contact_email value’, different from it’s ‘user’ value.

I updated this value and now the new user with this email provided by SAML can log into Seafile.

Thank you !