import_data: fails with IntegrityError when the account's own details already hold a number, address, link or identifier #375
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#375
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, reading the archive importer and loading small archives into an account whose profile was already filled in.Checked again on 2026-10-01 against
mainat0a5cad587: still present.The archive importer restores the profile's telephone numbers, postal addresses, web links and person identifiers as if the profile were empty. It chooses the primary row only among the archive's own rows and never looks at what the holder already has, so the one-primary constraints refuse the insert; a value the profile already holds is refused by the per-holder uniqueness rules in the same way.
account_is_emptydoes not count any of these, so an account whose owner has only filled in Your details passes the guard and the whole import then rolls back with a raw traceback.core/importer.py:198-225,_restore_web_links;:228-260,_restore_postal_addresses;:263-297,_restore_phone_numbers:primary_takenstarts empty orFalseandseenholds only the archive's rows.core/importer.py:380-388:PersonIdentifier.objects.get_or_create(profile=..., scheme=..., value=...)clashes with the one-per-scheme constraint when the profile holds the same scheme with another value.core/importer.py:130-138,account_is_empty: looks at applications, companies, CVs and experience only.core/management/commands/import_data.py:35: catchesArchiveErrorandBadZipFileonly.account_is_emptytrue in every case):UNIQUE constraint failed: core_weblink.content_type_id, core_weblink.object_id, core_weblink.kind;... core_weblink.url;... core_postaladdress.content_type_id, core_postaladdress.object_id; the same address:... core_postaladdress.owner_id, core_postaladdress.comparable;... core_phonenumber.content_type_id, core_phonenumber.object_id;... accounts_personidentifier.profile_id, accounts_personidentifier.scheme.resume/candidate.py:1315,_hang: "The primary the account has stays the primary"); the archive importer does not.primary_takenandseenfrom the holder's existing rows (by kind for links, bycomparable_form()for addresses, by URL for links).account_is_emptyor say in its docstring and the command's help that they do not count.ImportReport.skipped, and turn any remainingIntegrityErrorinto anArchiveErrorwith a readable message.Done when
tests/test_backup.py(or a newtests/test_import_into_filled_profile.py): for each of web link, postal address, telephone number and person identifier, importing an archive into an account whose profile already has a primary row of that kind succeeds, keeps the existing primary, and lists anything skipped in the report.tiagoagueda referenced this issue2026-10-03 01:59:01 +00:00