Your details: adding a telephone number or a postal address crashes, because the new row is given no owner #454
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#454
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, by reading how Your details saves its rows and then posting a new row toaccounts:profilein a test.Checked again on 2026-10-01 against
mainat0a5cad587: still present. The code is now atcore/phone_numbers.py:302-383(BasePhoneNumberFormSet);accounts/views.py:182-187,core/postal.pyandcore/mixins.pyhave not moved, and the same two posts raise the same two errors.Your details cannot add a telephone number or a postal address.
ProfileView.form_validbinds the two formsets to the profile and saves them without giving the new rows an owner.PhoneNumberandPostalAddressareOwnedModels, andowneris not nullable. Nothing else fills it in: not the forms (fieldsarekind,labelandnumber, or the address parts), not the formsets, not the models'save(). The insert fails, the page answers 500, and the transaction takes the rest of the page's changes with it.accounts/views.py:182-187(ProfileView.form_valid:numbers.instance = self.object; numbers.save()andaddresses.instance = self.object; addresses.save());core/phone_numbers.py:325-377(BasePhoneNumberFormSet) andcore/postal.py:245-285(BasePostalAddressFormSet), neither of which setsownerinsave_new. Comparecore/mixins.py:107-114(WebLinksMixin.save_web_links) andcore/mixins.py:165-176(PhoneNumbersMixin.save_phone_numbers), which both setform.instance.ownerbefore saving; the profile's web links go through the first, but its numbers and addresses do not go through the second.IntegrityError: NOT NULL constraint failed: core_phonenumber.owner_id(orcore_postaladdress.owner_id) and returns 500. Reproduced by postingphone_numbers-0-number_0=PT,phone_numbers-0-number_1=912345678and, separately, one address row toaccounts:profile: both raise, and no row is written. Editing rows that already exist works, because they carry their owner from when they were created.save_newinBasePhoneNumberFormSetandBasePostalAddressFormSet(asBaseWebLinkFormSet.save_newalready does forkind) to setform.instance.ownerfrom the holder, with theholder.owner if hasattr(holder, "owner") else holder.userrule thatcore/mixins.pyrepeats twice moved into one helper beside them.PhoneNumbersMixin.save_phone_numbersandWebLinksMixin.save_web_linkscan then drop their own loops.Done when
tests/test_phone_numbers.pyposts a new number toaccounts:profileand finds it saved with the account as owner; it fails today with theIntegrityError.tests/test_postal_addresses.pydoes the same for a new address.