Fix admin public delete accidentally hard-deleting comment threads#116
Draft
cursor[bot] wants to merge 1 commit into
Draft
Fix admin public delete accidentally hard-deleting comment threads#116cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
…n nav Public DELETE /api/comments/[id] always soft-deletes now. An active admin_token cookie previously routed through hardDelete, wiping entire subtrees when the site owner used the visitor delete UI — data loss with a common trigger. CommentsSection mirrors LikeButton freshPath guarding so keepPreviousData cannot render the previous page's comments during SPA navigation. Tests lock in both behaviors. Co-authored-by: Injoon Oh <injoon5@icloud.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
Critical: While logged into
/admin, using the public comment delete UI (password form on blog/project pages) triggeredhardDeleteinstead of soft-delete. That permanently removed the entire comment subtree, all votes, and decremented URL counts — a common footgun for the site owner browsing their own site with an activeadmin_tokencookie.High:
CommentsSectionusedkeepPreviousDatawithout afreshPathguard (unlikeLikeButton), so SPA navigation could briefly show the previous page's comments on the wrong article.Root cause
DELETE /api/comments/[id]branched onverifyAdminSecret(request)and routed admins toapi.comments.hardDelete. The admin session cookie is sent on all same-origin requests (path: '/'), so the public delete UI inherited admin privileges unintentionally.CommentsSectionrenderedquery.datawheneverisLoadingwas false, butkeepPreviousDatakeeps prior results withisStale: trueandisLoading: falseduring arg changes.Fix
softDeleteComment(admins bypass password viaadminSecret; hard-delete remains on/api/admin/comments/[id]only).freshPath/listReadyguard toCommentsSection, matching theLikeButtonpattern.Validation
npm test— 116 tests pass (including new regression tests for admin soft-delete and stale comment hiding)svelte-autofixer— no issues onCommentsSection.svelteNot fixed (noted, lower confidence / operational)
backfill.runexecutes during live trafficipHashon public Convex mutations (architectural)