Project

General

Profile

Actions

Bug #106120

closed

sync-ldap-users, IntegrityError: new row for relation "authentic2_userexternalid" violates check constraint "at_least_one_id"

Added by Sentry Io 8 months ago. Updated 29 days ago.

Status:
Solution déployée
Priority:
Normal
Category:
-
Target version:
-
Start date:
23 May 2025
Due date:
% Done:

0%

Estimated time:
Patch proposed:
No
Planning:
No

Description

Lors de sync-ldap-users, cette trace,

https://sentry.entrouvert.org/entrouvert/publik/issues/140327/

CheckViolation: new row for relation "authentic2_userexternalid" violates check constraint "at_least_one_id" 
DETAIL:  Failing row contains (1709, mutualisation.fr, null, 2020-05-04 14:27:14.270765+00, 2020-05-04 14:27:14.270815+00, 1709, null).

  File "django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)

IntegrityError: new row for relation "authentic2_userexternalid" violates check constraint "at_least_one_id" 
DETAIL:  Failing row contains (1709, mutualisation.fr, null, 2020-05-04 14:27:14.270765+00, 2020-05-04 14:27:14.270815+00, 1709, null).

(14 additional frame(s) were not displayed)
...
  File "django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)

Command sync-ldap-users failed: /usr/lib/authentic2/manage.py sync-ldap-users
Actions #1

Updated by Frédéric Péters 8 months ago

  • Project changed from 369 to Authentic 2
Actions #3

Updated by Paul Marillonnet (retour le 19/01) 3 months ago

  • Status changed from Nouveau to En cours
  • Assignee set to Paul Marillonnet (retour le 19/01)

🤖 Une pull request concernant ce ticket a été ouverte :

Actions #4

Updated by Paul Marillonnet (retour le 19/01) 3 months ago

  • Status changed from En cours to Solution proposée
Actions #5

Updated by Nicolas Roche 3 months ago

  • Status changed from Solution proposée to Solution validée

🤖 Pull request approuvée :

Actions #6

Updated by Benjamin Dauvergne 3 months ago

Si c'est bien un AD c'est pas possible de ne pas avoir de objectGUID c'est l'identifiant interne de la base je pense https://learn.microsoft.com/fr-fr/openspecs/windows_protocols/ms-adts/dd4dc725-021b-4c8c-a44a-49b3235836b7 .

Il vaudrait mieux planter proprement (bloquer le compte, ne pas le synchroniser) si pas de GUID quelque soit son nom (entryuuid, objectguid & co).

Actions #7

Updated by Benjamin Dauvergne 3 months ago

D'ailleurs si je regarde la base il n'y a aucun compte sans guid et actif:

In [19]: UserExternalId.objects.filter(external_guid__isnull=True, user__is_active=True).count()
Out[19]: 0

In [20]: UserExternalId.objects.filter(external_guid__isnull=True, user__is_active=False).count()
Out[20]: 436

en plus la PR casse l'objectif du commentaire juste avant de garantir l'unicité des paires (source, eid), (source, eguid).

Il manque je pense un test pour montrer ce que ça doit faire et pourquoi ça devrait le faire.

Actions #8

Updated by Benjamin Dauvergne 3 months ago

  • Status changed from Solution validée to En cours

🤖 Modifications demandées sur la pull request :

Actions #9

Updated by Benjamin Dauvergne 2 months ago

En repassant sur ce ticket je pense que ce sont de vieux comptes disparus avant l'introduction des guid qui ont pu poser problème, un compte sans guid et donc on veut mettre le external_id à None, on en supprime le UserExternalId tout simplement, y a pas d'autre choix pour conserver la contrainte (mais un test vérifiant ces hypothèses serait bien à minima).

Actions #10

Updated by Paul Marillonnet (retour le 19/01) about 1 month ago

  • Status changed from En cours to Solution proposée
Actions #11

Updated by Paul Marillonnet (retour le 19/01) about 1 month ago

🤖 Relecture de Benjamin Dauvergne (bdauvergne) demandée sur la pull request :

Actions #12

Updated by Benjamin Dauvergne about 1 month ago

  • Status changed from Solution proposée to Solution validée

🤖 Pull request approuvée :

Actions #13

Updated by Paul Marillonnet (retour le 19/01) about 1 month ago

  • Status changed from Solution validée to Résolu (à déployer)

🤖 Pull request fusionnée :

Actions #14

Updated by Transition automatique 29 days ago

  • Status changed from Résolu (à déployer) to Solution déployée
Actions

Also available in: Atom PDF