From bd4067cf83a54152690f41a804d4944877644161 Mon Sep 17 00:00:00 2001 From: Paulo Victor Cordeiro <146781332+pvcordeiro@users.noreply.github.com> Date: Thu, 4 Jun 2026 04:06:10 +0100 Subject: [PATCH] fix: guard remaining uid.decode() calls in auto-classify spam path (#1860) Two more bare uid.decode() calls at lines 889 and 897 crash with AttributeError when uid is already a string. Applies the same isinstance guard used everywhere else in this function. --- routes/email_pollers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/email_pollers.py b/routes/email_pollers.py index 529ba00..7bed2f6 100644 --- a/routes/email_pollers.py +++ b/routes/email_pollers.py @@ -886,7 +886,7 @@ async def _auto_summarize_pass_single(days_back: int = 1, account_id: str | None if is_spam and auto_spam and spam_folder: if _imap_move(uid, spam_folder, account_id=account_id, owner=account_owner): moved_to = spam_folder - logger.info(f"Auto-spam moved uid={uid.decode()} to {spam_folder}: {spam_reason}") + logger.info(f"Auto-spam moved uid={uid.decode() if isinstance(uid, bytes) else str(uid)} to {spam_folder}: {spam_reason}") _c = _sql3.connect(SCHEDULED_DB) _c.execute(""" @@ -894,7 +894,7 @@ async def _auto_summarize_pass_single(days_back: int = 1, account_id: str | None (message_id, owner, uid, folder, subject, sender, tags, spam_verdict, spam_reason, moved_to, model_used, created_at) VALUES (?, ?, ?, 'INBOX', ?, ?, ?, ?, ?, ?, ?, ?) - """, (message_id, account_owner or "", uid.decode(), subject, sender, + """, (message_id, account_owner or "", uid.decode() if isinstance(uid, bytes) else str(uid), subject, sender, json.dumps(tags), 1 if is_spam else 0, spam_reason, moved_to, model, datetime.utcnow().isoformat())) _c.commit()