test(gateway): regression: every adapter.connect() must accept is_reconnect

The gateway reconnect watcher forwards is_reconnect=True to every
adapter.connect() call on every retry. Adapters whose signature omits
the kwarg raise TypeError at every reconnect attempt and stay silently
disconnected — the exact bug that shipped for QQAdapter and only
surfaced after messages stopped flowing on the QQ channel for hours.

This test statically parses every adapter.py under gateway/platforms/
and plugins/platforms/ (via AST, so third-party SDKs like slack_sdk,
matrix-nio, aiohttp, telegram, etc. are NOT required in the test env)
and asserts every *Adapter class with an async connect() accepts
is_reconnect — either as a keyword-only argument or absorbed by
**kwargs.

Also fixes plugins/platforms/wecom/callback_adapter.py:WecomCallbackAdapter,
which the new test caught as a second offender. Same class of bug: bare
'async def connect(self)' signature would die on the first reconnect.

Companion to #59429 (which fixed the original QQAdapter offender).
This commit is contained in:
lemonwan 2026-07-06 14:25:55 +08:00 committed by Teknium
parent 276542c729
commit 0f8603c571
2 changed files with 164 additions and 1 deletions

View file

@ -115,7 +115,13 @@ class WecomCallbackAdapter(BasePlatformAdapter):
# Lifecycle
# ------------------------------------------------------------------
async def connect(self) -> bool:
async def connect(self, *, is_reconnect: bool = False) -> bool:
# ``is_reconnect`` is forwarded by GatewayRunner on every retry per
# the BasePlatformAdapter.connect contract. Callback adapters have
# no server-side queue to preserve, so the flag is accepted-and-
# ignored — but the kwarg MUST be present or the reconnect watcher
# dies with TypeError and the platform silently stays offline.
del is_reconnect
if not self._apps:
logger.warning("[WecomCallback] No callback apps configured")
return False