Skip to content

Keep a listing when its record is deleted but a duplicate survives - #71

Open
hipstersmoothie wants to merge 1 commit into
mainfrom
sesh/keep-listing-when-duplicate-record-deleted
Open

hipstersmoothie wants to merge 1 commit into
mainfrom
sesh/keep-listing-when-duplicate-record-deleted

Conversation

@hipstersmoothie

Copy link
Copy Markdown
Collaborator

Problem

ZelkTV disappeared from the store after being approved. The owner had two listing.detail records for it, created 4 minutes apart (likely a retried create), both with slug zelk-tv. The approved row pointed at the first one. Once that record was deleted from their PDS, Tap ingest's delete handler removed the row by repo + rkey. The second record was still live, but the listing went to a 404 and its favorites cascaded away with the row.

Fix

Before deleting, markListingRemovedFromTap lists the repo's live listing.detail records. If another one still describes the listing (same slug, otherwise same product URL), it does three things instead of deleting:

  • moves the row onto that record (at_uri / rkey)
  • adds the deleted URI to prior_at_uris, so favorites and reviews written against it still resolve
  • re-runs the normal upsert, which keeps the row's verification status because repo + rkey now match

If there's no survivor or the PDS can't be listed, it deletes as before. The in-app delete paths remove the row themselves first, so they're unaffected.

Prod

ZelkTV is already restored by hand: rehydrated from the surviving record, marked verified, old URI added to prior_at_uris, and both favorites re-ingested.

Testing

  • Unit tests for findSurvivingListingRecord (vitest run src/lib/atproto/tap-listing-sync.test.ts)
  • tsc --noEmit and oxlint are clean on the changed files
  • The repoint path was not run against a real DB

🤖 Generated with Claude Code

An owner whose create was retried can end up with two listing.detail
records for one listing. If they delete the one the store row points at,
Tap ingest deleted the row, taking an approved listing off the store
(along with its favorites and reviews) even though the other record was
still live. That's what happened to ZelkTV.

Now the delete handler looks for another live record in the same repo
with the row's slug (or product URL) and moves the row onto it, keeping
its moderation status and recording the deleted URI in prior_at_uris.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant