From db6ef4d67463efdfb4f18934cd013d3809578231 Mon Sep 17 00:00:00 2001 From: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com> Date: Sun, 27 Sep 2026 09:27:42 +0100 Subject: [PATCH] fix(weixin): silence polling request logs Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com> --- nanobot/channels/weixin/runtime.py | 2 ++ .../weixin/tests/test_weixin_hardening.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/nanobot/channels/weixin/runtime.py b/nanobot/channels/weixin/runtime.py index ff1449c4b..9a5772254 100644 --- a/nanobot/channels/weixin/runtime.py +++ b/nanobot/channels/weixin/runtime.py @@ -37,6 +37,7 @@ from nanobot.bus.queue import MessageBus from nanobot.channels.base import BaseChannel from nanobot.config.paths import get_media_dir, get_runtime_subdir from nanobot.config.schema import Base +from nanobot.utils.logging_bridge import redirect_lib_logging # --------------------------------------------------------------------------- # Protocol constants (from openclaw-weixin types.ts) @@ -996,6 +997,7 @@ class WeixinChannel(BaseChannel): self._client = None async def start(self) -> None: + redirect_lib_logging("httpx", level="WARNING") self._running = True self._next_poll_timeout_s = self.config.poll_timeout self._client = self._new_http_client( diff --git a/nanobot/channels/weixin/tests/test_weixin_hardening.py b/nanobot/channels/weixin/tests/test_weixin_hardening.py index 534c2b5b3..bce910e84 100644 --- a/nanobot/channels/weixin/tests/test_weixin_hardening.py +++ b/nanobot/channels/weixin/tests/test_weixin_hardening.py @@ -3,7 +3,7 @@ from __future__ import annotations import asyncio import json import time -from unittest.mock import AsyncMock +from unittest.mock import AsyncMock, Mock import httpx import pytest @@ -74,6 +74,22 @@ def test_reply_progress_opt_in_enables_progress_transport() -> None: assert config.send_tool_hints is True +@pytest.mark.asyncio +async def test_start_suppresses_httpx_polling_logs(monkeypatch) -> None: + channel = _channel(token="bot-token") + redirect = Mock() + monkeypatch.setattr("nanobot.channels.weixin.runtime.redirect_lib_logging", redirect) + monkeypatch.setattr(channel, "_notify_lifecycle", AsyncMock()) + + async def poll_once() -> None: + channel._running = False + + monkeypatch.setattr(channel, "_poll_once", poll_once) + await channel.start() + + redirect.assert_called_once_with("httpx", level="WARNING") + + @pytest.mark.parametrize( ("section", "send_progress", "send_tool_hints"), [