Account import: a telephone number already held on the instance is dropped without a line in the report #562

Closed
opened 2026-10-01 10:47:39 +00:00 by tiagoagueda · 0 comments
Owner

Found on 2026-09-29 in a read-only review of postulo at 95348908d, reading the account importer's restore helpers.

Checked again on 2026-10-01 against main at 0a5cad587: still present. The code is now at core/phone_numbers.py:123 (taken_elsewhere); core/importer.py and import_data.py have not moved.

Telephone numbers are unique across the instance, so the importer deliberately skips any number some row here already holds. That choice is right, but the skip is silent: _restore_phone_numbers is not handed the ImportReport, so nothing is added to report.skipped, and import_data prints nothing about it. Every other thing the importer leaves behind (a translation with no record, a missing file, an unreadable remembered place) gets a line there, which is what the report is for.

  • Where: core/importer.py:263-297 (_restore_phone_numbers; the skip is if taken_elsewhere(number): continue at :277), called from :373 for the profile and :522 for each contact, neither with the report. core/management/commands/import_data.py:38-41 prints only report.as_lines() and report.skipped.
  • What happens: an account is exported and imported into a second account on the same instance while the first still exists (a move between accounts, or a trial import). The profile's numbers and every contact's numbers already exist, so taken_elsewhere() (core/phone_numbers.py:146) is true for each and all of them are skipped. The command prints its counts and "Imported into …", and nothing says that the numbers did not come across. The same happens to any single number another account on the instance happens to hold, and to the second of two records in one archive that share a number.
  • Why it matters: the operator reads a clean report and tells the person the move is complete; the numbers are found missing later, when the old account may already be gone.
  • Fix: pass the report into _restore_phone_numbers and append a line per skipped row that names the record in the archive, not the account that holds the number, for example "Telephone number ending 45 on the profile: already recorded on this instance, not restored". The output reaches only the operator running the command.

Done when

  • A test in tests/test_phone_numbers.py imports an archive whose profile number is already held by other_user and asserts that the number is not restored and that report.skipped has exactly one line mentioning it, without naming other_user.
Found on 2026-09-29 in a read-only review of postulo at 95348908d, reading the account importer's restore helpers. Checked again on 2026-10-01 against `main` at `0a5cad587`: still present. The code is now at `core/phone_numbers.py:123` (`taken_elsewhere`); `core/importer.py` and `import_data.py` have not moved. Telephone numbers are unique across the instance, so the importer deliberately skips any number some row here already holds. That choice is right, but the skip is silent: `_restore_phone_numbers` is not handed the `ImportReport`, so nothing is added to `report.skipped`, and `import_data` prints nothing about it. Every other thing the importer leaves behind (a translation with no record, a missing file, an unreadable remembered place) gets a line there, which is what the report is for. - **Where:** `core/importer.py:263-297` (`_restore_phone_numbers`; the skip is `if taken_elsewhere(number): continue` at `:277`), called from `:373` for the profile and `:522` for each contact, neither with the report. `core/management/commands/import_data.py:38-41` prints only `report.as_lines()` and `report.skipped`. - **What happens:** an account is exported and imported into a second account on the same instance while the first still exists (a move between accounts, or a trial import). The profile's numbers and every contact's numbers already exist, so `taken_elsewhere()` (`core/phone_numbers.py:146`) is true for each and all of them are skipped. The command prints its counts and "Imported into …", and nothing says that the numbers did not come across. The same happens to any single number another account on the instance happens to hold, and to the second of two records in one archive that share a number. - **Why it matters:** the operator reads a clean report and tells the person the move is complete; the numbers are found missing later, when the old account may already be gone. - **Fix:** pass the report into `_restore_phone_numbers` and append a line per skipped row that names the record in the archive, not the account that holds the number, for example "Telephone number ending 45 on the profile: already recorded on this instance, not restored". The output reaches only the operator running the command. ## Done when - A test in `tests/test_phone_numbers.py` imports an archive whose profile number is already held by `other_user` and asserts that the number is not restored and that `report.skipped` has exactly one line mentioning it, without naming `other_user`.
tiagoagueda added this to the 0.6.0 milestone 2026-10-01 10:47:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
Postulo/postulo#562
No description provided.