From d2ed6670c1c81496190a9ab0503c8adf01bc2a23 Mon Sep 17 00:00:00 2001 From: Xare123 <57245242+Xare123@users.noreply.github.com> Date: Sat, 15 Aug 2026 17:32:00 -0700 Subject: [PATCH] Make swallowed message uniqueness failures observable --- lib/database/io/message.dart | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/database/io/message.dart b/lib/database/io/message.dart index 4440c2ef6a..b1bd2a15fa 100644 --- a/lib/database/io/message.dart +++ b/lib/database/io/message.dart @@ -794,7 +794,15 @@ class Message { try { if (chat != null) this.chat.target = chat; id = Database.messages.put(this); - } on UniqueViolationException catch (_) {} + } on UniqueViolationException catch (ex, stack) { + // Still swallowed, because callers rely on save() not throwing. But no + // longer silent: on this path `id` stays null and the message is + // returned as though it had been persisted, so nothing downstream can + // distinguish a saved message from a dropped one. replaceMessage + // already logs this exact constraint below; these two sites did not. + Logger.error('Failed to save message! This is likely due to a unique constraint being violated.', + error: ex, trace: stack); + } }); return this; } @@ -860,7 +868,13 @@ class Message { for (int i = 0; i < messages.length; i++) { messages[i].id = ids[i]; } - } on UniqueViolationException catch (_) {} + } on UniqueViolationException catch (ex, stack) { + // The reaction-linking pass above did not persist. The ids assigned by + // the earlier putMany still stand, so this is narrower than the save() + // case, but it is the same invisible failure and worth seeing. + Logger.error('Failed to bulk save messages! This is likely due to a unique constraint being violated.', + error: ex, trace: stack); + } }); return messages; }