From c69310c625f212179fe1820e8ca9b59433c064ad Mon Sep 17 00:00:00 2001 From: teknium1 Date: Tue, 28 Apr 2026 05:00:16 -0700 Subject: [PATCH] fix(weixin): raise descriptive error when rate-limit retries exhaust The rate-limit branch added by the original PR did sleep+continue with no attempt to record the last error, so persistent iLink -2 responses exhausted the retry loop and hit 'assert last_error is not None', raising AssertionError instead of a descriptive RuntimeError. Record last_error = RuntimeError(...) before continuing, and break out of the loop on the final attempt instead of sleeping uselessly. --- gateway/platforms/weixin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gateway/platforms/weixin.py b/gateway/platforms/weixin.py index 5445c6fd..426d6e27 100644 --- a/gateway/platforms/weixin.py +++ b/gateway/platforms/weixin.py @@ -1538,7 +1538,16 @@ class WeixinAdapter(BasePlatformAdapter): or errcode == RATE_LIMIT_ERRCODE ) if is_rate_limited: - wait = self._send_chunk_retry_delay_seconds * 3 # 3s backoff for rate limit + errmsg = resp.get("errmsg") or resp.get("msg") or "rate limited" + # Record the error so we raise a descriptive + # RuntimeError (instead of AssertionError) if the + # loop exhausts with the server still rate-limiting. + last_error = RuntimeError( + f"iLink sendmessage rate limited: ret={ret} errcode={errcode} errmsg={errmsg}" + ) + if attempt >= self._send_chunk_retries: + break + wait = self._send_chunk_retry_delay_seconds * 3 # 3x backoff for rate limit logger.warning( "[%s] rate limited for %s; backing off %.1fs before retry", self.name, _safe_id(chat_id), wait,