Web links: the same address under two kinds crashes Your details and the contact form #457
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#457
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 the web link formsets against the model's constraints and posting the case toaccounts:profilein a test.Checked again on 2026-10-01 against
mainat0a5cad587: still present. None of the cited locations has moved, and the two-block post raises the same error.A holder's web links are unique on the address across all three kinds (
web_link_unique_per_holder), but each check that guards that uniqueness sees only one kind at a time. When the same address is typed under two kinds in one save, the form is accepted, and the second insert breaks the constraint. The result is a 500 with nothing saved.core/models.py:677-680: theweb_link_unique_per_holderconstraint on(content_type, object_id, url).core/web_links.py:308-324(BaseWebLinkFormSet.clean):alreadyholds the holder's saved addresses, andseenholds only this formset's rows. Social profiles, code repositories and websites are three formsets (formsets_for,:377-389), and none of them sees what another is adding in the same POST.core/web_links.py:209-242(save_only_link, the single box used while a kind's feature is off): it looks for a hidden row of the same kind only (holder.web_links.filter(kind=kind, url=typed)) and then saves, with no check against other kinds.core/mixins.py:104-114(WebLinksMixin.web_links_invalidandsave_web_links) validates and saves the formsets one by one.https://github.com/meunder both Code repositories and Websites on Your details (or on a contact) and saves. Both formsets validate, and the second insert raisesIntegrityError: UNIQUE constraint failed: core_weblink.content_type_id, core_weblink.object_id, core_weblink.url. The same happens with two single boxes while the features are off, and with one box and one block. With every link feature off, typing the website's address into the repository box as well is enough. Both the two-block case and the two-box case were reproduced againstaccounts:profile.(content_type, object_id, kind, url), changealreadyinBaseWebLinkFormSet.cleantoholder.web_links.filter(kind=self.kind), and add a migration.WebLinksMixin.web_links_invalidor in the form'sclean, and put "This address is already listed." on the later one.save_only_linkshould then check other kinds before saving.Related to #305, which reworks these rows around a chosen service but does not touch the uniqueness rule.
Done when
tests/test_web_links.pyposts the same address underrepositoriesandwebsitestoaccounts:profileand gets either both rows saved or the form back with the error. Today it raisesIntegrityError.