From 7c1eefc142c951d7db5a0fa1afeae64a2fdf02fd Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 17 May 2026 23:50:16 -0700 Subject: don't remove orphan payment ids from user payment lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the underlying payment record is missing, removing the id from the user's payments list was destructive — a transiently unavailable record (arc fallback miss, database hiccup) would cause us to permanently drop the pointer. Leave the orphan in place so a back-fill from an RDB backup can restore the record under the same id later. Co-Authored-By: Claude Opus 4.7 (1M context) --- routes/payments.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/routes/payments.ts b/routes/payments.ts index 65086afd..7cdf8923 100644 --- a/routes/payments.ts +++ b/routes/payments.ts @@ -202,14 +202,16 @@ export default { const paymentKeys = payments.map((pid) => `payment:${pid}`); const fetched = await gfAll(paymentKeys); - const missingIds: any[] = []; const validPayments: any[] = []; for (let i = 0; i < fetched.length; i++) { const p = fetched[i]; if (!p) { + // Don't lRem the id — the underlying record may be temporarily + // unavailable (arc fallback miss, transient db issue) and we'd + // permanently lose the user's payment history pointer. Leave the + // orphan in the list so a back-fill from a backup can restore it. warn("user", id, "missing payment", payments[i]); - missingIds.push(payments[i]); continue; } if (received && p.amount < 0) continue; @@ -217,10 +219,6 @@ export default { validPayments.push(p); } - if (missingIds.length) { - for (const pid of missingIds) await db.lRem(listKey, 0, pid); - } - const internalRefs = [...new Set( validPayments .filter((p) => p.type === PaymentType.internal && p.ref) -- cgit v1.2.3