Development #41342
IntegrityError sur import de rôles
0%
Description
Export d'un export de rôles de recette, import sur une prod,
IntegrityError at /manage/site-import/ duplicate key value violates unique constraint "a2_rbac_role_name_unique_idx_0" DETAIL: Key (name, ou_id)=(Debug & Support Entr'ouvert, 1) already exists.
Dans l'export,
"name": "Debug & Support Entr'ouvert", "slug": "debug-eo",
mais ce rôle existe déjà sur la production, avec un autre slug,
"name": "Debug & Support Entr'ouvert", "slug": "debug-support-entrouvert",
(et il y a un rôle "Debug EO" qui a le slug "debug-eo").
Il faudrait que l'erreur soit remontée de manière intelligible.
Fichiers
Révisions associées
data_transfer: use ValidationError instead of DataImportError (#41342)
data_transfer: validate models before updating/creating them (#41342)
To prevent collision between roles when altering their name and their
slug is already unique. Ex.:
R1(slug=a, name=A) import> R1(slug=a, name=B)
R2(slug=b, name=B)
tests: remove unused variable (#41342)
misc: move lazy_label in a2.utils.lazy (#41342)
misc: clean dead imports (#41342)
Historique
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
- Fichier 0002-tests-remove-unused-variable-41342.patch 0002-tests-remove-unused-variable-41342.patch ajouté
- Fichier 0001-data_transfer-validate-uniqueness-of-roles-41342.patch 0001-data_transfer-validate-uniqueness-of-roles-41342.patch ajouté
- Tracker changé de Bug à Development
- Statut changé de Nouveau à Solution proposée
- Patch proposed changé de Non à Oui
C'est pas magnifique mais ça fait le job.
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
- Fichier Firefox_Screenshot_2020-04-09T15-03-55.736Z.png Firefox_Screenshot_2020-04-09T15-03-55.736Z.png ajouté
Ça affichera suffisamment d'information pour trouver l'origine du problème (voir screenshot, on a le type, l'attribut et la valeur concerné, et le souci).
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
- Fichier 0002-tests-remove-unused-variable-41342.patch 0002-tests-remove-unused-variable-41342.patch ajouté
- Fichier 0001-data_transfer-validate-uniqueness-of-roles-41342.patch 0001-data_transfer-validate-uniqueness-of-roles-41342.patch ajouté
Tests pas re-testés. On remarquera que j'ai mis le patch qui sert à rien en dernier.
Mis à jour par Paul Marillonnet il y a environ 4 ans
Je pense que la logique derrière le bout de code
if e.args and isinstance(e.args[0], ValidationError): […] else: […]
devrait être prise en charge dans une méthode magique
DataImportError.__str__
nouvellement définie et non pas à l'impromptu dans la méthode SiteImportView.form_valid
.Mis à jour par Benjamin Dauvergne il y a environ 4 ans
- Fichier 0002-tests-remove-unused-variable-41342.patch 0002-tests-remove-unused-variable-41342.patch ajouté
- Fichier 0001-data_transfer-validate-uniqueness-of-roles-41342.patch 0001-data_transfer-validate-uniqueness-of-roles-41342.patch ajouté
Ejection de DataImportError, on ne travaille plus qu'avec ValidationError.
Mis à jour par Paul Marillonnet il y a environ 4 ans
- Je pense que ce serait plus clair en proposant un premier patch qui abandonne DataImportError.
- Pourquoi défaire la listcomp (ligne 310 de
data_transfer.py
) ?
- Je pense qu'on peut mettre la création de
authentic2.utils.lazy
dans un patch à part, en profitant pour y inclure le décorateurauthentic2.utils.lazy_label
et en faisant les corrections d'import.
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
Paul Marillonnet a écrit :
- Pourquoi défaire la listcomp (ligne 310 de
data_transfer.py
) ?
Pas très lisible.
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
- Fichier 0001-utils-add-a-lazy_join-function-41342.patch 0001-utils-add-a-lazy_join-function-41342.patch ajouté
- Fichier 0002-data_transfer-use-ValidationError-instead-of-DataImp.patch 0002-data_transfer-use-ValidationError-instead-of-DataImp.patch ajouté
- Fichier 0003-data_transfer-validate-models-before-updating-creati.patch 0003-data_transfer-validate-models-before-updating-creati.patch ajouté
- Fichier 0004-tests-remove-unused-variable-41342.patch 0004-tests-remove-unused-variable-41342.patch ajouté
Mis à jour par Paul Marillonnet il y a environ 4 ans
- Statut changé de Solution proposée à Solution validée
À toi de voir mais je continue de penser qu'il faudrait déplacer le lazy_label
déjà existant dans le module authentic2.utils.lazy
nouvellement créé. Sinon à part ça, ack.
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
- Statut changé de Solution validée à Résolu (à déployer)
commit 1b6a8561eee1007a5b39d2dc1daf9e704209794a Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Thu Apr 16 12:35:23 2020 +0200 misc: clean dead imports (#41342) commit 673557b3015d48861d2e8ff45555cb0fb057c477 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Thu Apr 16 12:35:04 2020 +0200 misc: move lazy_label in a2.utils.lazy (#41342) commit 30439cada09bccf098f251c9f6d53e0f2dab48c2 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Thu Apr 9 16:14:50 2020 +0200 tests: remove unused variable (#41342) commit 52ab85eb5b87b2723e7d9c6fb70d692334e96da5 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Wed Apr 15 11:29:21 2020 +0200 data_transfer: validate models before updating/creating them (#41342) To prevent collision between roles when altering their name and their slug is already unique. Ex.: R1(slug=a, name=A) -import-> R1(slug=a, name=B) R2(slug=b, name=B) commit 8f5aadf89fbc0544f1de94825ced8e03467ae1d3 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Thu Apr 9 16:15:20 2020 +0200 data_transfer: use ValidationError instead of DataImportError (#41342) commit 7b8ed451807b4d038d80c4fbb420df798deac6c2 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Wed Apr 15 11:25:24 2020 +0200 utils: add a lazy_join function (#41342) Use it to join translated strings.
Mis à jour par Frédéric Péters il y a environ 4 ans
- Statut changé de Résolu (à déployer) à Solution déployée
utils: add a lazy_join function (#41342)
Use it to join translated strings.