domain: frozen-slug invariant not enforced in update_post, web editor can rename a live permalink #55
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
rosa/vernier#55
Loading…
Add table
Add a link
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 during a code review of the
domaincrate.Location:
crates/domain/src/services.rs:920(update_post); invariant inCONTEXT.mdandcrates/domain/src/models/post.rs:505Severity: Correctness — documented invariant bypassed
Problem
CONTEXT.md and the
PostEditdoc state the slug is frozen once set. Only the Micropub path enforces it (by copying the old slug);update_postnever checksedit.slug == old_post.slug(), and the web edit form buildsPostEditfrom a user-editable slug field, so a web edit silently renames a live post permalink.Failure scenario
A user edits a published post in the web editor and changes the slug.
update_postwrites the new slug, so every external link, feed entry, and previously-sent webmention source pointing at the old permalink now 404s.Suggested fix
Either drop
slugfromPostEdit(derive it from the loaded post) or rejectedit.slug != old_post.slug()inupdate_post. If renaming is actually intended, update the domain docs and model it explicitly. Note: the doc comment cites ADR-0004, but ADR-0004 does not mention slugs — fix that citation too.