Repository navigation
fix(channels): use the system proxy for the Slack Web API and Telegram - #34175
jeeshofone wants to merge 2 commits into
Conversation
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
20dbc7b to
ad87da0
Compare
|
GPT F1 (empty registry value swallows the next record): fixed in ad87da0. |
|
GPT F2 (Telegram ignores the discovered NO_PROXY): not changed in this PR, as the adjudication downgraded it. The Telegram client's per-request proxy choice ( |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS One reader for Slack Web API and Telegram proxies replaces two environment-only readers. Three other channel resolvers that read only the environment are still unfixed. Notes
What this change shipsInventory (7 items) — 4 justifiedIntent: Windows users on proxy-only networks can use the Slack and Telegram channels through the system proxy. FIX.
[FIRST-PRINCIPLES-REVIEWED] 752a9fd Description read[DESCRIPTION-READ] a3b0d219d44c0bb2845408a2f58d0b6839a446ba9f3237f063926824d9ce4e36 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the Slack Web API clients and Telegram now get their proxy from the same reader as the websocket, which fixes the cause of the two legs disagreeing. Any regression is reversible. Notes
[DESIGN-REVIEWED] 752a9fd Description read[DESCRIPTION-READ] a03fc9b83d32d942d07f83340d63ff5773e221a9ab47c6ab4bdb607700b0b69a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
ad87da0 to
73b6378
Compare
|
GPT on ad87da0 (Telegram ignores the discovered bypass list, raised again for a |
Code change approver recommendation: A person should decideAutomated, not a person, and not a review: a maintainer still decides.
Why: the decider approves but is not confident enough to auto-approve (p_defect 0.12 > 0.10). Adds Windows system-proxy discovery from the per-user Internet Settings registry key (WinINet), at the same point the macOS reader already uses. reg.exe runs from the Windows directory the kernel names; that check is now one shared helper in find-bin.js, and the ssh.exe lookup behaves as before. The bypass rule matches the macOS reader: when NO_PROXY cannot express the system's bypass (, wildcards like 10.*, uncopyable entries, a setup script beside the manual server), nothing is set. Discovery still runs only when the environment has no proxy variable. Tests cover the parser, the per-protocol list, every case that discovers nothing, the exact reg.exe call, an unproven root and a failed read. I found no regression on macOS or Linux and no trust-boundary problem. If this recommendation is wrong, reply here; the replies are how the approver is evaluated. |
73b6378 to
4019d49
Compare
|
GPT F1 on 73b6378 (Telegram ignores the discovered bypass list and the protocol split): fixed in 4019d49, in two places.
|
4019d49 to
4ced254
Compare
|
GPT F1 on 4019d49 (token verification ignores the discovered bypass): fixed in 4ced254. The client and the dashboard token check now share one rule, The First Principles comment still shows its verdict on ad87da0 (the duplicated kernel system-root lookup). That was fixed in 73b6378: |
4ced254 to
787bb74
Compare
|
GPT F1 on 4ced254 (port-specific bypass ignored): fixed in 787bb74. This head also adds |
|
Thanks for pinning the two remaining guards and adding the doc sentence. One item still needs a decision on this head. You have said there is no Windows host on your side, so a maintainer decides how it clears.
Earlier review, item by item:
Optional:
|
0b808ae to
883def0
Compare
|
Head 883def0 covers the three optional items from the 06:44 comment:
Item 1 still waits on a run from a Windows host, or on a maintainer accepting the CI probe instead. |
883def0 to
7d380fc
Compare
|
First Principles BLOCK on 883def0 (discovered proxy variables reaching every |
|
GPT 6.1 on 883def0:
|
|
Following the 06:44 comment and the lane findings on 883def0, head 7d380fc re-scopes this PR. The Windows mismatch came from the |
7d380fc to
b96a064
Compare
|
GPT 6.1 F1 on 7d380fc ( |
b96a064 to
864c7e3
Compare
|
Design Review BLOCK on b96a064 (the registry proxy path never ran on Windows): head 864c7e3 records that run. Fork-only evidence run 44887726747 executed this PR's
The run also showed that a Windows |
|
Item 1 (a real-Windows run): now recorded under |
|
GPT 6.1 F1 on 864c7e3 (the module-level |
b043735 to
9e5ce0e
Compare
|
Opus 5.5 BLOCK on b043735 (the scheme filter also dropped an operator's own |
|
GPT 6.1 F1 on b043735 (a registry |
9e5ce0e to
9894214
Compare
|
Rebased onto current main (8bd64a2) with no content change: both commits are identical in |
|
Thanks for the re-scope. The review found no blocking defect on this head, and my earlier change request is resolved. It still needs a maintainer before it can merge. Earlier review, item by item:
What the review checked on this head:
What a maintainer still decides:
Optional:
|
Withdrawn: every item in this review is fixed or answered on the current head (see the follow-up comment). Other holds on this PR are listed there.
The Slack websocket and the gateway's aiohttp calls pick their proxy with http_proxy.resolve_proxy, which on Windows falls back to the registry through urllib.request.getproxies. The slack_sdk Web API clients were built with no proxy, so they read the environment only, and Telegram's resolver did the same. On a Windows host whose only egress is the system proxy, the two legs of one channel took different routes. Pass proxy=resolve_proxy(SLACK_API_URL) at every slack_sdk client the gateway builds, and let Telegram fall back to resolve_proxy when no proxy variable is set. Nothing is exported to kiro-cli or any other child. The shared bypass check now matches host and host:port, and no longer raises on an out-of-range port. Fixes kirodotdev#34152
resolve_proxy warns once per process for each proxy scheme it cannot use, so a test that drives the warning would hide it from every later test on the same xdist worker. Clear the set before and after each test, the way the neighbouring _reset_* fixtures in conftest_resets.py do.
Problem / Motivation
Goal: On Windows, the Slack and Telegram channels reach the network through the system proxy set in Settings > Network > Proxy, and every leg of a channel takes the same route.
On a Windows host whose only way out is the system proxy, the Slack Web API call and Telegram's startup call go direct and fail. The Slack websocket finds the proxy through urllib's registry fallback, so the two legs of one channel disagree. Slack drops to dashboard-only until the next restart, and Telegram reports unreachable.
Why it matters
Windows users on proxy-only corporate networks cannot use the Slack or Telegram channels unless they set proxy variables by hand and launch the app from that shell.
Not a goal
What changed (motivation → approach → change)
The two legs of one channel disagree because they read the proxy differently. The Slack websocket and the gateway's aiohttp calls take their proxy from
kiro_crew.http_proxy.resolve_proxy, which usesurllib.request.getproxies(). On Windows that falls back to the registry (getproxies_registry) when no proxy variable is set. Theslack_sdkWeb API clients were built with noproxy=, so they read only the environment (load_http_proxy_from_env). Telegram's own resolver also read only the environment.The fix is to have the readers that disagree use the reader that already works:
slack_sdkWebClient/AsyncWebClientthe gateway builds now passesproxy=resolve_proxy(SLACK_API_URL). There are 10 sites:slack/events.py,slack/client.py,slack/owner_claim.py,slack/reconnect.py,slack/enterprise.py,dashboard/messaging_api/slack_settings.py,dashboard/slack_code_settings.py,dashboard/slack_shared_access.py, and two incli_setup.py. Each resolves once, when the client is built._resolve_proxy(telegram/client_http.py) still prefers a proxy variable, and otherwise asksresolve_proxyfor the Bot API host.resolve_proxytakes the first of the HTTPS and HTTP entries the HTTP clients can use (http://orhttps://). A Windowssocks=entry, which the standard library turns intosocks4://, is skipped, sohttp=...;socks=...still uses the HTTP entry. With no usable entry it logs once and the client connects direct, as with no proxy at all. A proxy variable the operator set is returned exactly as on main, whatever its scheme.http_proxy.is_bypassedis the bypass rule forresolve_proxyand Slack Socket Mode, which reads the OS bypass list too. It matches the bare host orhost:port, and an out-of-range port falls back to the scheme default instead of raising. Telegram's per-request choice uses main'shttp_proxy.proxy_for_url(from fix(channels): honour NO_PROXY in discord, webex and wecom clients #40488), which readsNO_PROXYonly, so it does no lookup on the event loop.docs/guides/windows-install.mdgains a troubleshooting entry.Nothing is exported to any child process.
kiro-cli, every agent harness, MCP servers andagent.envsee exactly the environment they see on main. Only the gateway's own Slack and Telegram clients change.Changed since the last review
http_proxy.proxy_for_url, an environment-onlyNO_PROXYcheck per request. This head drops theenvironment_onlymode it had added tois_bypassedfor the same job, and Telegram callsproxy_for_urlinstead, so there is one environment-only helper, not two.This head replaces the Electron discovery with the reader fix above.
reg.exereader inwebsite/electron/system-proxy-env.js, its merge ingateway-env.js, thefind-bin.jssystem-root export, their tests and registry fixtures, and the Windowsreg queryprobe step in.github/workflows/ci.yml. Every file underwebsite/and.github/is now identical to main.resolve_proxyrefuses a proxy scheme the clients cannot use, and the Windows run above is recorded.kiro-clichild unverified, and the Captain's item 1 asked for a real-Windows run of that path. With nothing exported, that path no longer exists. Withci.ymlback to main's, the Fork workflow-change guard has nothing to block.Backwards compatibility
Compatible: a proxy variable set in the environment still wins everywhere, as on main.
Removes nothing: on Linux
getproxies()reads only the environment, so nothing changes there. On Windows and macOS, the Slack Web API clients and Telegram now also use the OS proxy settings when no variable is set, the same route the Socket Mode and aiohttp legs already took on main. Telegram also honoursNO_PROXYon every platform, as Slack andresolve_proxyalready did.Tests
test/test_slack_client_proxy.py: a source scan fails if anyWebClient/AsyncWebClientconstruction undersrc/omitsproxy=. It goes red with one site'sproxy=removed. Two site tests (dashboard/slack_shared_access.py,slack/owner_claim.py) check that the resolved proxy, orNone, reaches the client.test/test_telegram_client.py: a proxy variable wins over the OS settings, and with no variable the OS reader is asked for the Bot API host (red with the fallback removed). Also theNO_PROXYexact-host,.suffixandhost:443cases, andtest_proxy_choice_never_asks_the_os_matcher, a regression pin for the event-loop rule that already passes on main.test/test_channel_token_check_proxy.py: thetelegram-no-proxy-basecase, where the dashboard token check sends aNO_PROXYbase host direct.test/test_http_proxy.py:test_only_a_proxy_the_clients_can_use_is_returnedcovers the single-server and per-protocol forms, which return the proxy, and the Windowssocks=form andsocks5://, which return None. The two SOCKS rows are red with the scheme check removed.test_an_environment_proxy_passes_through_unchangedandtest_an_environment_proxy_wins_over_the_os_and_passes_throughcheck that an environmentsocks5://or schemeless value is returned unchanged, through the real environment lookup and the Windows dispatch. All four go red if the filter is applied to the environment. Thehttp-plus-socksrow (http=...;socks=...) returns the HTTP entry, and goes red if only the HTTPS entry is considered. Also, anhttpsURL ending in:99999does not raise, on both the environment and OS paths, and the bare-host bypass still applies. Both cases are red with theexceptremoved. The OS case pinsproxy_bypassto the environment matcher, so it never reads the host's own settings.test_cli_setup_slack.py,test_env_credential_secret_refs.py) now acceptproxy=.5,247 related tests pass. black, isort, flake8, mypy, Semgrep (diff-only, as CI runs it) and the comment-history gate are clean.
Proof: not provable -- other: each new test was checked by reverting its own production hunk, and prove.py was not run on this reshaped head.
Real-machine verification
Recorded on a real Windows host: run 44887726747 of a fork-only evidence workflow (
.github/workflows/windows-proxy-evidence.ymlon the orphan branchevidence/34175-windows-proxyof jeeshofone/KiroCrew; it changes nothing in this PR).windows-latest, Microsoft Windows Server 2025 Datacenter 10.0.26100 (imagewin25-vs202620261116.315.1), Python 3.12.10, slack_sdk 3.48.0, aiohttp 3.14.5.src/diff at commit 864c7e3, applied to base b6091e4. This head changes onlyresolve_proxy's handling of an environment value and anhttp=...;socks=...registry entry. Neither changes the result of any of the six cases, because no proxy variable is set and none of them combineshttp=withsocks=.host:port. No proxy variable is set in any case; the step prints the environment to show it. For each case the workflow writes the WinINETInternet Settingskey withreg add, prints the rawreg queryoutput, and then in a fresh process printsgetproxies()andresolve_proxy(...). It then calls Slackauth.testandapps.connections.openwith bogus tokens through bothWebClientandAsyncWebClient, and TelegramgetMethroughTelegramClient. A completed call returnsinvalid_author401 Unauthorized.reg query)resolve_proxySlack / TelegramProxyEnable 0x1,ProxyServer 127.0.0.1:3128http://127.0.0.1:3128/ sameapi.telegram.org:443,slack.com:443ProxyEnable 0x0,ProxyServer 127.0.0.1:3128ProxyEnable 0x0,AutoConfigURL http://127.0.0.1:9/proxy.pacProxyEnable 0x1,ProxyServer http=127.0.0.1:3128;https=127.0.0.1:3128http://127.0.0.1:3128/ sameapi.telegram.org:443,slack.com:443ProxyEnable 0x1,ProxyServer socks=127.0.0.1:1080AsyncWebClientcompleted directslack.comProxyOverride slack.com;<local>http://127.0.0.1:3128api.telegram.org:443onlygetproxies()returned{'http': 'http://127.0.0.1:3128', 'https': 'http://127.0.0.1:3128', 'ftp': ...}in cases 1 and 6 and{'http': ..., 'https': ...}in case 4. So a Windowshttps=entry already comes back ashttp://. In case 5 it returned{'socks': 'socks://127.0.0.1:1080', 'http': 'socks4://127.0.0.1:1080', 'https': 'socks4://127.0.0.1:1080'}, whichresolve_proxynow refuses. The full rawreg queryoutput for every case is in the run log.Not exercised: the Socket Mode websocket leg itself, which needs a real app token (its Web API call,
apps.connections.open, was exercised); real Slack and Telegram tokens; desktop Windows 11; and an authenticating (NTLM, Kerberos) proxy.Known limits
socks5://or schemelessHTTPS_PROXYstill reaches the client and fails closed there.WebClientused bycli_setup.pyandslack/enterprise.pystill fails, because its urllib transport reads the registry'ssocks4://itself when given no proxy. Case 5 shows it, and main behaves the same way.Manual verification
The run above is the manual verification. It was not repeated on a desktop Windows 11 machine.
Related Issues
Fixes #34152
Relationship: #40488 (merged, fixes #40249) made Discord, Webex and WeCom honour
NO_PROXYthroughproxy_for_url; this PR now reuses that helper for Telegram. Not covered: those three channels still do not read the OS proxy settings.Sibling sweep
Swept: git grep -nE "AsyncWebClient(|WebClient(" -- src/
Sibling: src/kiro_crew/slack/events.py -- changed here
Sibling: src/kiro_crew/cli_setup.py -- changed here
Sibling: src/kiro_crew/discord/client.py --
NO_PROXYfixed in #40488; OS settings not readPattern harvest
Rule candidate: lint
Pattern: an HTTP client library that reads proxies from the environment itself, built without an explicit proxy from the shared resolver (now pinned for slack_sdk by
test_slack_client_proxy.py).Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.