From 100219f6643684061a898c85295b7d8da1db008f Mon Sep 17 00:00:00 2001 From: aameobius Date: Sat, 8 Aug 2026 19:20:17 +0300 Subject: [PATCH] fix(cron): surface exception type and traceback for standalone Discord delivery errors --- cron/scheduler.py | 8 ++++++-- plugins/platforms/discord/adapter.py | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cron/scheduler.py b/cron/scheduler.py index 0177b278f927b..b9ce3c55d588e 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -2230,8 +2230,12 @@ def _deliver_result(job: dict, content: str, adapters=None, loop=None) -> Option continue if result and result.get("error"): - msg = f"delivery error: {result['error']}" - logger.error("Job '%s': %s", job["id"], msg) + # Include target context (platform/chat) so a bare error string + # like "Discord send failed: TimeoutError: " is attributable; + # no active exception here (error comes from the send result), + # so exc_info is only attached when one is in flight. + msg = f"delivery error: {result['error']} (target {platform_name}:{chat_id})" + logger.error("Job '%s': %s", job["id"], msg, exc_info=sys.exc_info()[0] is not None) target_errors.extend([msg]) delivery_errors.extend(target_errors) continue diff --git a/plugins/platforms/discord/adapter.py b/plugins/platforms/discord/adapter.py index cd3b2b0166d43..10d2e32cd4252 100644 --- a/plugins/platforms/discord/adapter.py +++ b/plugins/platforms/discord/adapter.py @@ -9805,7 +9805,10 @@ async def _standalone_send( result["warnings"] = warnings return result except Exception as e: - return {"error": _standalone_sanitize_error(f"Discord send failed: {e}")} + # Include the exception type: TimeoutError().str() is empty, so + # "Discord send failed: " alone gave no diagnostic signal. + logger.error("Discord standalone send failed", exc_info=True) + return {"error": _standalone_sanitize_error(f"Discord send failed: {type(e).__name__}: {e}")} # ── Plugin entry point ────────────────────────────────────────────────────────