fix(weixin,wecom,matrix): respect system proxy via aiohttp trust_env - #8280
Closed
MaybeRichard wants to merge 1 commit into
Closed
fix(weixin,wecom,matrix): respect system proxy via aiohttp trust_env#8280MaybeRichard wants to merge 1 commit into
MaybeRichard wants to merge 1 commit into
Conversation
aiohttp.ClientSession defaults to trust_env=False, ignoring HTTP_PROXY/ HTTPS_PROXY env vars. This causes QR login and all API calls to fail for users behind a proxy (e.g. Clash in fake-ip mode), which is common in China where Weixin and WeCom are primarily used. Added trust_env=True to all aiohttp.ClientSession instantiations that connect to external hosts (weixin: 3 places, wecom: 1, matrix: 1). WhatsApp sessions are excluded as they only connect to localhost. httpx-based adapters (dingtalk, signal, wecom_callback) are unaffected as httpx defaults to trust_env=True. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Cherry-picked with authorship preserved into PR #8680 (now merged). Thank you @MaybeRichard for the fix — proxy support is critical for the Chinese user base. |
luigileap
added a commit
to luigileap/hermes-agent
that referenced
this pull request
Apr 16, 2026
PR NousResearch#8280 (commit cac6178, "fix(gateway): propagate user identity through process watcher pipeline") added an early-return guard in `GatewayRunner._handle_message`: elif source.user_id is None: logger.debug("Ignoring message with no user_id from %s", ...) return None This catches Telegram service messages, channel forwards, and anonymous admin actions that previously triggered spurious pairing flows. `test_session_hygiene_messages_stay_in_originating_topic` built a `SessionSource` without `user_id`, so after the guard landed the handler returned `None` before reaching `_run_agent`, and the assertion `assert result == "ok"` failed. Set `user_id="795544298"` on the synthetic source — matching the same numeric user already used as `TELEGRAM_HOME_CHANNEL` elsewhere in the test — so the event looks like a normal authorised message and the handler runs the agent path the test is meant to cover.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
aiohttp.ClientSessiondefaults totrust_env=False, which means it ignoresHTTP_PROXY/HTTPS_PROXYenvironment variables. For users behind a proxy (e.g. Clash in fake-ip mode — common in China), DNS resolves to fake IPs that only work when traffic is routed through the proxy. Since aiohttp bypasses the proxy entirely, QR login and all subsequent API calls silently fail.This is especially impactful for Weixin and WeCom, which are Chinese services almost exclusively accessed through a proxy in practice.
Fix
Added
trust_env=Trueto allaiohttp.ClientSessioninstantiations that connect to external hosts:gateway/platforms/weixin.pygateway/platforms/wecom.pygateway/platforms/matrix.pyWhatsApp sessions are intentionally excluded — they only connect to
127.0.0.1(local bridge), where proxy routing is not needed.httpx-based adapters (
dingtalk,signal,wecom_callback) are unaffected — httpx already defaults totrust_env=True.Impact
trust_env=Trueis a no-op when no proxy env vars are set)