Your details: saving the page untouched stores an empty telephone row where the chooser has a default country #649

Closed
opened 2026-10-01 20:48:15 +00:00 by tiagoagueda · 0 comments
Owner

Found while reviewing #304; it reproduces identically on be9b6febc, before that change.

What happens

Open Your details in a language whose locale gives the telephone chooser a default country
(English, French, Portuguese: most of them) and press Save without touching anything.
A telephone row with an empty number is created. If the account had no number, the empty
row becomes the primary one.

In a language where the chooser starts empty (Ukrainian, for one) it does not happen.

Why

The blank extra row of the formset posts ["GB", ""]: the country the chooser started at
and no number. Its initial value is None. MultiValueField.has_changed compares the two
part by part against decompress(None), finds the country different, and calls the row
changed; the formset then saves it, and PhoneNumber(number="") is stored.

What should happen

A row nobody typed a number into is not a change. PhoneField.has_changed should treat an
initial of None as decompress(""), so a chooser that merely shows its default is not
something the person did.

Acceptance

  • Saving Your details untouched, in a language with a default country, creates no row.
  • The same on a contact's form.
  • A test that fails without the fix, at the form and through the page.
  • A data migration is not asked for: an existing empty row is visible on the page and can be
    removed there. Say so in the changelog line.
Found while reviewing #304; it reproduces identically on `be9b6febc`, before that change. ## What happens Open *Your details* in a language whose locale gives the telephone chooser a default country (English, French, Portuguese: most of them) and press *Save* without touching anything. A telephone row with an empty number is created. If the account had no number, the empty row becomes the primary one. In a language where the chooser starts empty (Ukrainian, for one) it does not happen. ## Why The blank extra row of the formset posts `["GB", ""]`: the country the chooser started at and no number. Its initial value is `None`. `MultiValueField.has_changed` compares the two part by part against `decompress(None)`, finds the country different, and calls the row changed; the formset then saves it, and `PhoneNumber(number="")` is stored. ## What should happen A row nobody typed a number into is not a change. `PhoneField.has_changed` should treat an initial of `None` as `decompress("")`, so a chooser that merely shows its default is not something the person did. ## Acceptance - Saving *Your details* untouched, in a language with a default country, creates no row. - The same on a contact's form. - A test that fails without the fix, at the form and through the page. - A data migration is not asked for: an existing empty row is visible on the page and can be removed there. Say so in the changelog line.
tiagoagueda added this to the 0.5.0 milestone 2026-10-01 20:48:15 +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#649
No description provided.