Skip to content

fix(channels): use the system proxy for the Slack Web API and Telegram - #34175

Open
jeeshofone wants to merge 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/34152-windows-system-proxy
Open

jeeshofone wants to merge 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/34152-windows-system-proxy

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Reading a setup script (PAC). Like the macOS reader, a PAC configuration discovers nothing.
  • Changing the channel clients themselves. They already honour the standard proxy variables.
  • Linux discovery.

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 uses urllib.request.getproxies(). On Windows that falls back to the registry (getproxies_registry) when no proxy variable is set. The slack_sdk Web API clients were built with no proxy=, 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:

  • Every slack_sdk WebClient/AsyncWebClient the gateway builds now passes proxy=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 in cli_setup.py. Each resolves once, when the client is built.
  • Telegram's _resolve_proxy (telegram/client_http.py) still prefers a proxy variable, and otherwise asks resolve_proxy for the Bot API host.
  • When the proxy comes from the OS settings (no proxy variable set), resolve_proxy takes the first of the HTTPS and HTTP entries the HTTP clients can use (http:// or https://). A Windows socks= entry, which the standard library turns into socks4://, is skipped, so http=...;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_bypassed is the bypass rule for resolve_proxy and Slack Socket Mode, which reads the OS bypass list too. It matches the bare host or host:port, and an out-of-range port falls back to the scheme default instead of raising. Telegram's per-request choice uses main's http_proxy.proxy_for_url (from fix(channels): honour NO_PROXY in discord, webex and wecom clients #40488), which reads NO_PROXY only, so it does no lookup on the event loop.
  • docs/guides/windows-install.md gains a troubleshooting entry.

Nothing is exported to any child process. kiro-cli, every agent harness, MCP servers and agent.env see exactly the environment they see on main. Only the gateway's own Slack and Telegram clients change.

Changed since the last review

  • Rebase onto fix(channels): honour NO_PROXY in discord, webex and wecom clients #40488: main now has http_proxy.proxy_for_url, an environment-only NO_PROXY check per request. This head drops the environment_only mode it had added to is_bypassed for the same job, and Telegram calls proxy_for_url instead, so there is one environment-only helper, not two.
    This head replaces the Electron discovery with the reader fix above.
  • Removed: the Windows reg.exe reader in website/electron/system-proxy-env.js, its merge in gateway-env.js, the find-bin.js system-root export, their tests and registry fixtures, and the Windows reg query probe step in .github/workflows/ci.yml. Every file under website/ and .github/ is now identical to main.
  • Since b96a064: resolve_proxy refuses a proxy scheme the clients cannot use, and the Windows run above is recorded.
  • Why: the First Principles and Design lanes blocked on the discovered variables reaching every kiro-cli child unverified, and the Captain's item 1 asked for a real-Windows run of that path. With nothing exported, that path no longer exists. With ci.yml back to main's, the Fork workflow-change guard has nothing to block.
  • Frozen sections: "Not a goal" still says the channel clients are not changed. That line predates this re-scope and now conflicts with the diff. It is left as written because those sections change only on a maintainer's request.

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 honours NO_PROXY on every platform, as Slack and resolve_proxy already did.

Tests

  • test/test_slack_client_proxy.py: a source scan fails if any WebClient/AsyncWebClient construction under src/ omits proxy=. It goes red with one site's proxy= removed. Two site tests (dashboard/slack_shared_access.py, slack/owner_claim.py) check that the resolved proxy, or None, 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 the NO_PROXY exact-host, .suffix and host:443 cases, and test_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: the telegram-no-proxy-base case, where the dashboard token check sends a NO_PROXY base host direct.
  • test/test_http_proxy.py: test_only_a_proxy_the_clients_can_use_is_returned covers the single-server and per-protocol forms, which return the proxy, and the Windows socks= form and socks5://, which return None. The two SOCKS rows are red with the scheme check removed. test_an_environment_proxy_passes_through_unchanged and test_an_environment_proxy_wins_over_the_os_and_passes_through check that an environment socks5:// 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. The http-plus-socks row (http=...;socks=...) returns the HTTP entry, and goes red if only the HTTPS entry is considered. Also, an https URL ending in :99999 does not raise, on both the environment and OS paths, and the bare-host bypass still applies. Both cases are red with the except removed. The OS case pins proxy_bypass to the environment matcher, so it never reads the host's own settings.
  • Two existing fake Slack clients (test_cli_setup_slack.py, test_env_credential_secret_refs.py) now accept proxy=.

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.yml on the orphan branch evidence/34175-windows-proxy of jeeshofone/KiroCrew; it changes nothing in this PR).

  • Host: GitHub-hosted windows-latest, Microsoft Windows Server 2025 Datacenter 10.0.26100 (image win25-vs2026 20261116.315.1), Python 3.12.10, slack_sdk 3.48.0, aiohttp 3.14.5.
  • Code: this PR's src/ diff at commit 864c7e3, applied to base b6091e4. This head changes only resolve_proxy's handling of an environment value and an http=...;socks=... registry entry. Neither changes the result of any of the six cases, because no proxy variable is set and none of them combines http= with socks=.
  • Method: a local logging proxy on 127.0.0.1:3128 accepts CONNECT and records each 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 WinINET Internet Settings key with reg add, prints the raw reg query output, and then in a fresh process prints getproxies() and resolve_proxy(...). It then calls Slack auth.test and apps.connections.open with bogus tokens through both WebClient and AsyncWebClient, and Telegram getMe through TelegramClient. A completed call returns invalid_auth or 401 Unauthorized.
Case Registry (from reg query) resolve_proxy Slack / Telegram Proxy CONNECT log Result
1 manual proxy ProxyEnable 0x1, ProxyServer 127.0.0.1:3128 http://127.0.0.1:3128 / same api.telegram.org:443, slack.com:443 all calls completed through the proxy
2 proxy off ProxyEnable 0x0, ProxyServer 127.0.0.1:3128 None / None empty all calls completed direct
3 PAC only ProxyEnable 0x0, AutoConfigURL http://127.0.0.1:9/proxy.pac None / None empty all calls completed direct
4 per-protocol ProxyEnable 0x1, ProxyServer http=127.0.0.1:3128;https=127.0.0.1:3128 http://127.0.0.1:3128 / same api.telegram.org:443, slack.com:443 all calls completed through the proxy
5 SOCKS only ProxyEnable 0x1, ProxyServer socks=127.0.0.1:1080 None / None empty Telegram and AsyncWebClient completed direct
6 bypass slack.com case 1 plus ProxyOverride slack.com;<local> None / http://127.0.0.1:3128 api.telegram.org:443 only Slack direct, Telegram through the proxy

getproxies() 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 Windows https= entry already comes back as http://. 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'}, which resolve_proxy now refuses. The full raw reg query output 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

  • Each Slack client and the Telegram client resolve the proxy once, when they are built, on the event loop. That is one bounded OS lookup per client. Before this change the aiohttp legs did it on every request.
  • The scheme filter applies only to values from the OS settings. A proxy variable the operator set is passed through unchanged, as on main, so a socks5:// or schemeless HTTPS_PROXY still reaches the client and fails closed there.
  • With a SOCKS-only registry setting, the sync WebClient used by cli_setup.py and slack/enterprise.py still fails, because its urllib transport reads the registry's socks4:// itself when given no proxy. Case 5 shows it, and main behaves the same way.
  • These are the WinINET settings that Windows Settings, Edge and Chrome use. A proxy set only in Firefox's own dialog leaves the registry empty, so the gateway connects direct, as before.

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_PROXY through proxy_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_PROXY fixed in #40488; OS settings not read

Pattern 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@jeeshofone
jeeshofone requested review from a team and KiroCrewCaptain as code owners November 9, 2026 23:06
@jeeshofone
jeeshofone requested a review from CrysisDeu November 9, 2026 23:06
@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 752a9fdc2893800a83781136c71f58200c7a7fab via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 752a9fd

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 752a9fdc2893800a83781136c71f58200c7a7fab via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 752a9fd

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from 20dbc7b to ad87da0 Compare November 9, 2026 23:29
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 9, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT F1 (empty registry value swallows the next record): fixed in ad87da0. parseRegQuery now splits columns on spaces and tabs only ([ \t]) and allows a trailing \r, so an empty REG_SZ value stays empty and the next line is read as its own record. New test: "an empty registry value does not swallow the next value" in website/electron/test/system-proxy-env.test.js. It puts an empty AutoConfigURL and an empty ProxyOverride ahead of ProxyServer. It fails on 20dbc7b and passes on this head.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

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 (telegram/client_http.py _proxy_for / _resolve_proxy) already ignores NO_PROXY for any proxy variable, including the macOS discovery path and a hand-set HTTPS_PROXY, so this PR does not introduce the gap. Hitting it needs a manual Windows proxy that lists api.telegram.org in its bypass list and also blocks Telegram. When that happens, the channel shows as disconnected, and setting any proxy variable in the environment turns discovery off. Making that client honour NO_PROXY touches the path whose URL carries the bot token, so it belongs in its own change.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 752a9fdc2893800a83781136c71f58200c7a7fab touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 752a9fdc2893800a83781136c71f58200c7a7fab via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 2 — symptom-level (siblings): the cause is that each channel resolves its proxy from the environment only. I grepped for var in ("HTTPS_PROXY" and found 3 copies left: wecom/client.py:1209, webex/client.py:1340 and the env list at discord/client.py:1056. Subtraction: defer. Later, replace each loop with http_proxy.resolve_proxy, as Telegram's fallback now does.
  • Item 4 — rides along: "a Windows socks= entry… is skipped" adds a new state, _warned_schemes, and a new autouse conftest reset. Subtraction: drop _warned_schemes/_warn_unusable_scheme and log at debug level each time, which also removes _reset_http_proxy_warned_schemes.

What this change ships

Inventory (7 items) — 4 justified

Intent: Windows users on proxy-only networks can use the Slack and Telegram channels through the system proxy. FIX.

  1. Slack Web API clients (10 of 10 WebClient/AsyncWebClient sites in src/) now use the OS proxy when no proxy variable is set — justified
  2. Telegram falls back to the OS proxy for the Bot API host — justified
  3. Telegram's client and its dashboard token check now honour NO_PROXY on every platform — rides along
  4. A SOCKS or other unusable OS proxy is skipped with a one-time warning, and the client connects direct — rides along
  5. The duplicated Socket Mode bypass check is merged into http_proxy.is_bypassed — justified
  6. An out-of-range URL port no longer makes the bypass check raise — rides along
  7. Windows troubleshooting entry in the install guide — justified

[FIRST-PRINCIPLES-REVIEWED] 752a9fd

Description read

[DESCRIPTION-READ] a3b0d219d44c0bb2845408a2f58d0b6839a446ba9f3237f063926824d9ce4e36

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 752a9fdc2893800a83781136c71f58200c7a7fab via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • The description says "Only the gateway's own Slack and Telegram clients change", which is not quite true. The new SOCKS-scheme filter in resolve_proxy also applies to every other caller: auth/refresh.py, auth/login/*, teams/client.py, _update_feed.py and wakatime. On those paths, an OS proxy set to SOCKS now logs a warning and connects direct instead of raising in aiohttp. That is probably the better behaviour, but the description should say so.
  • Telegram's _resolve_proxy now calls the OS matcher (proxy_bypass) once, from TelegramClient.__init__. It is the same one-time startup lookup Slack Socket Mode already makes, so it is fine as long as nobody starts calling it per request.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 9, 2026
@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from ad87da0 to 73b6378 Compare November 10, 2026 00:08
@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT on ad87da0 (Telegram ignores the discovered bypass list, raised again for a TELEGRAM_API_BASE_URL mirror): not changed here, as the adjudication downgraded it. telegram/client_http.py already ignores NO_PROXY for any proxy variable, on macOS discovery and for a hand-set HTTPS_PROXY, so this PR does not create the gap. The failure shows at startup as "Telegram unreachable", and setting any proxy variable, NO_PROXY included, turns discovery off, as docs/guides/windows-install.md says. Adding a bypass matcher to the Telegram transport is a Python change to the path that carries the bot token, so it belongs in its own PR. Head is now 73b6378, which also shares the kernel system-root lookup with find-bin.js for the First Principles finding.

@Zedmor

Zedmor commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Code change approver recommendation: A person should decide

Automated, not a person, and not a review: a maintainer still decides.

decider-v3c@217fe607 · p_defect 0.12 · router R0 (approves only when p_defect <= 0.10, on changes of at most 400 changed lines) · head 73b63785ac · 314 changed lines

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.

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from 73b6378 to 4019d49 Compare November 10, 2026 08:11
@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT F1 on 73b6378 (Telegram ignores the discovered bypass list and the protocol split): fixed in 4019d49, in two places.

  • telegram/client_http.py _proxy_for now sends a host on NO_PROXY direct, using the stdlib matcher urllib.request.proxy_bypass_environment. The loopback exemption is unchanged. Test: test_proxy_bypassed_for_no_proxy_host in test/test_telegram_client.py (exact host and .suffix bypassed, other hosts still proxied).
  • Windows discovery sets nothing for a ProxyServer list with no https= entry, because Windows sends HTTPS direct there while clients that fall back to HTTP_PROXY would proxy it. Test: the http=plain.example:3128 case in "a disabled, PAC-only or unrepresentable Windows proxy discovers nothing".
    Both tests fail with their fix reverted and pass on this head. This now touches the Telegram client, so it widens the earlier "Not a goal" line about channel clients; the change is limited to honouring NO_PROXY.

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from 4019d49 to 4ced254 Compare November 10, 2026 12:18
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 10, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT F1 on 4019d49 (token verification ignores the discovered bypass): fixed in 4ced254. The client and the dashboard token check now share one rule, _proxy_for_url(url, proxy) in telegram/client_http.py: loopback and NO_PROXY hosts go direct, everything else uses the resolved proxy. TelegramClient._proxy_for and _validate_telegram_token both call it, so the two paths cannot pick different routes for the same host. Test: the telegram-no-proxy-base case in test/test_channel_token_check_proxy.py, which fails with the fix reverted and passes on this head.

The First Principles comment still shows its verdict on ad87da0 (the duplicated kernel system-root lookup). That was fixed in 73b6378: system-proxy-env.js resolves the root through find-bin.js windowsSystemRoot and keeps no copy of the constant or the regex.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 10, 2026
@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from 4ced254 to 787bb74 Compare November 10, 2026 14:14
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 10, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT F1 on 4ced254 (port-specific bypass ignored): fixed in 787bb74. _proxy_for_url in telegram/client_http.py now checks both the bare host and host:port, where the port is the URL's own or the scheme default (443 for https). That is the same rule http_proxy.resolve_proxy already applies. Because the dashboard token check calls the same helper, it gets the fix too. Test: test_proxy_bypassed_for_no_proxy_host_with_port in test/test_telegram_client.py (NO_PROXY=api.telegram.org:443 sends the default-port URL direct and keeps :8443 on the proxy). It fails with the fix reverted and passes on this head.

This head also adds _proxy_for_url to the Telegram client facade's type-checking import block, which clears the test_facade_mirror_guards failure on Backend Tests (3.12, 7) and (Windows) (2).

@github-actions github-actions Bot added the readiness: passed Eligible automated validation passed for the current revision label Nov 21, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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.

  1. website/electron/system-proxy-env.js:420: the proxied Windows branch has still never run on a real Windows host. Trigger: a Windows host has a manual system proxy (ProxyEnable=1, ProxyServer set, no PAC, no <local>) and no inherited *_PROXY variable. Outcome: readWindowsProxyEnvironment exports HTTP_PROXY, HTTPS_PROXY and NO_PROXY to the whole gateway tree. That covers Slack, Telegram and every Kiro CLI child, so it changes the route of chat itself. Every test of that branch uses hand-written reg query text. The real reg.exe probe runs only on a runner with the proxy off, and its "discovers nothing" result is also what main returns on win32. ## Real-machine verification still says "Not done". AGENTS.md makes a base run and a head run the pass condition. The Design lane lists this as a Blocker on this head. Its header reads PASS only because the parser did not match the backticked Trigger and Outcome lines. Smallest fix: record one Windows run under ## Real-machine verification. Include the machine, raw reg query output with a manual proxy set, a base run and a head run of a Slack Web API call, Telegram getMe and one chat turn, the proxy variables the gateway received, one proxy-off or PAC-only host that discovers nothing, and cleanup. A Windows instance in your own AWS account counts. This item also clears if a maintainer posts a PR comment accepting the CI probe instead.

Earlier review, item by item:

  • End-to-end run on a real Windows machine: still stands (item 1).
  • What happens behind an NTLM or Kerberos proxy: answered. A 407 fails the call, traced in the code with file and line references.
  • Exact bypass entry becoming a suffix entry: fixed in docs/guides/windows-install.md.
  • wecom/client.py follow-up: fixed, it is now in Discord and Webex clients send every host through the proxy and ignore NO_PROXY #40249.
  • The UNSAFE_ENTRY and proxy host shape guards: fixed, both are now pinned by a test.
  • Telegram NO_PROXY change on every platform: no change needed from you. A maintainer still confirms it stays in this PR.

Optional:

  • website/electron/system-proxy-env.js:336: you can delete the host === "" guard and no test goes red. Without it, a ProxyServer of http:// or https=;http=plain.example:3128 exports HTTPS_PROXY=http://:80. Two rows in the "discovers nothing" table would pin it.
  • http_proxy.py:34: parsed.port raises ValueError on an out-of-range port such as a TELEGRAM_API_BASE_URL ending in :99999. The Telegram call paths catch only aiohttp.ClientError, so the error now escapes where main logged a transport error. A try/except ValueError around that read keeps the shared helper from raising.
  • docs/guides/windows-install.md:1074: a *.corp.example entry also sends the bare corp.example host direct. One more clause in the same sentence would cover it.

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from 0b808ae to 883def0 Compare November 21, 2026 07:05
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 21, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Head 883def0 covers the three optional items from the 06:44 comment:

  • src/kiro_crew/http_proxy.py: is_bypassed now catches the ValueError that an out-of-range port raises and falls back to the scheme's default port, so the shared helper never raises and the bare-host bypass check still runs. Pinned by test_bypass_check_does_not_raise_on_an_out_of_range_port in test/test_http_proxy.py, which covers both the environment and OS paths. Both cases fail with the except removed.
  • website/electron/system-proxy-env.js: the host === "" guard is now pinned by two rows in "a disabled, PAC-only or unrepresentable Windows proxy discovers nothing", ProxyServer http:// and https=;http=plain.example:3128. The table fails with the guard deleted.
  • docs/guides/windows-install.md: the bypass sentence now also says that a *.corp.example entry sends the bare corp.example host direct.

Item 1 still waits on a run from a Windows host, or on a maintainer accepting the CI probe instead. ## Real-machine verification still says it is not done.

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from 883def0 to 7d380fc Compare November 21, 2026 08:07
@jeeshofone jeeshofone changed the title fix(desktop): give the gateway the Windows system proxy fix(channels): use the system proxy for the Slack Web API and Telegram Nov 21, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles BLOCK on 883def0 (discovered proxy variables reaching every kiro-cli child, unverified): head 7d380fc removes the discovery. No proxy values are discovered or exported any more. The Windows reg.exe reader and its gateway-environment merge are gone, so kiro-cli, every agent harness, MCP servers and agent.env see exactly the environment they see on main. The fix is now in the readers: the slack_sdk Web API clients pass proxy=resolve_proxy(SLACK_API_URL), and Telegram falls back to resolve_proxy. That is the reader the Slack websocket and aiohttp legs already use, and on Windows it takes the system proxy from the registry through urllib.request.getproxies. A recorded run on a real Windows host is still not done. The description's ## Real-machine verification section lists what it would show.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT 6.1 on 883def0:

  • F2 (upheld, the OS case of the :99999 test reads the host's real bypass settings): fixed. The OS case now pins urllib.request.proxy_bypass to proxy_bypass_environment, as the neighbouring test does. Both cases are still red with the except removed.
  • F1 (downgraded, an exact Windows bypass entry becoming a suffix entry in NO_PROXY): no longer applies. Head 7d380fc exports nothing to NO_PROXY, so the registry bypass list is read as-is by the standard matcher (proxy_bypass_registry), with WinINet's own patterns.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Following the 06:44 comment and the lane findings on 883def0, head 7d380fc re-scopes this PR. The Windows mismatch came from the slack_sdk Web API clients and Telegram reading the environment only, while the other Slack legs used http_proxy.resolve_proxy, which on Windows reads the registry. The readers that disagreed now use that same helper. The Electron reg.exe discovery, the environment it exported to the gateway, and their tests are removed, so nothing reaches kiro-cli or any other child process. The CI change is withdrawn: .github/workflows/ci.yml is identical to main again, so the Windows reg query probe step is gone too. The :99999 port guard, the host:port bypass match and the Telegram NO_PROXY change remain. Item 1, a real-Windows run, is still not done. The description lists what it would show.

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from 7d380fc to b96a064 Compare November 21, 2026 08:34
@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT 6.1 F1 on 7d380fc (test_proxy_choice_never_asks_the_os_matcher depends on the host's system proxy): fixed in b96a064, test only. The test now pins urllib.request.getproxies to getproxies_environment, as the neighbouring tests pin proxy_bypass. So the proxy=None case reads the environment only and never this machine's own system proxy, and the raising proxy_bypass spy stays in place. The test still fails if client_http.py:187 is changed to environment_only=False, which is the behaviour it exists to pin.

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from b96a064 to 864c7e3 Compare November 21, 2026 09:14
@jeeshofone

Copy link
Copy Markdown
Contributor Author

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 src/ on a GitHub-hosted windows-latest (Windows Server 2025, 10.0.26100) with a local logging proxy and no proxy variable set. It ran six registry cases through reg add/reg query, with Slack auth.test and apps.connections.open (sync and async clients) and Telegram getMe:

  • a manual proxy, and a per-protocol http=;https= list, sent slack.com:443 and api.telegram.org:443 through the proxy;
  • the proxy off, and PAC only, resolved no proxy and connected direct;
  • a ProxyOverride of slack.com;<local> sent Slack direct and kept Telegram on the proxy.

The run also showed that a Windows socks= entry comes back from getproxies() as socks4://. resolve_proxy now refuses any scheme other than http/https, logs it once, and the clients connect direct, pinned in test/test_http_proxy.py. A per-protocol https= entry already comes back as http://, so nothing else changes. Not exercised: the Socket Mode websocket leg itself, real tokens, desktop Windows 11 and an authenticating proxy. The description's ## Real-machine verification has the table, and ## Known limits covers the one lookup per client at construction.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Item 1 (a real-Windows run): now recorded under ## Real-machine verification, from fork-only evidence run 44887726747 on a GitHub-hosted Windows Server 2025 runner.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT 6.1 F1 on 864c7e3 (the module-level _warned_schemes set has no shared per-test reset): fixed in b043735, test infrastructure only. test/conftest_resets.py gains _reset_http_proxy_warned_schemes, an autouse fixture that clears kiro_crew.http_proxy._warned_schemes before and after every test, in the same shape as the neighbouring _reset_* fixtures. It is bound through the existing conftest_resets import list in test/conftest.py. A scratch check with two tests that each expect the SOCKS warning passes with the reset in place. Without it, the second test fails because the warning was already given. http_proxy.py and its tests are unchanged.

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from b043735 to 9e5ce0e Compare November 21, 2026 10:21
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Opus 5.5 BLOCK on b043735 (the scheme filter also dropped an operator's own HTTPS_PROXY): fixed in 9e5ce0e. src/kiro_crew/http_proxy.py resolve_proxy now applies the http/https filter and the one-time warning only when urllib.request.getproxies_environment() is empty, which means the value came from the OS settings. When a proxy variable is set, the value is returned exactly as on main, whatever its scheme. So HTTPS_PROXY=socks5://... or a schemeless value still reaches the caller and fails closed there. That covers auth/refresh.py, auth/login/*, the update feed, the Slack response_url posts and _smoke_proxy. Pinned in test/test_http_proxy.py by test_an_environment_proxy_passes_through_unchanged (the real environment lookup) and test_an_environment_proxy_wins_over_the_os_and_passes_through (the Windows dispatch), each with socks5:// and schemeless values. All four are red with the filter applied to the environment. The OS-sourced socks4:// drop-and-warn rows stay green.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

GPT 6.1 F1 on b043735 (a registry http=...;socks=... setting discards the usable HTTP entry): fixed in 9e5ce0e. For an OS-sourced proxy, resolve_proxy in src/kiro_crew/http_proxy.py now takes the first of the HTTPS and HTTP entries with a usable scheme, then applies the bypass check. The socks4:// the standard library copies into HTTPS is skipped, and the HTTP CONNECT proxy is used. It connects direct only when neither entry is usable. Pinned by the http-plus-socks row of test_only_a_proxy_the_clients_can_use_is_returned in test/test_http_proxy.py, which goes red when only the HTTPS entry is considered.

@jeeshofone
jeeshofone force-pushed the fix/34152-windows-system-proxy branch from 9e5ce0e to 9894214 Compare November 21, 2026 11:19
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (8bd64a2) with no content change: both commits are identical in git range-diff. This picks up the docs-lint baseline fix (#40389), after main's red (#40399) reached the previous run's merge commit and failed Backend Tests (3.12, 5). The other red on that run, Backend Tests (3.12, 2) at test_many_data_literals_do_not_spend_decode_work, is the flake tracked in #39717.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 21, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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:

  • End-to-end Windows run of the proxied branch: no longer applies. The Electron reg.exe discovery and the environment it exported are removed, and nothing reaches Kiro CLI children any more. The new registry path has a recorded run on a GitHub-hosted Windows Server 2025 runner with six registry cases. That run used src at 864c7e3, and the only src change since then is the environment versus OS split in resolve_proxy, which does not change those six results.
  • NTLM or Kerberos behaviour, the exact and *. bypass doc notes, the wecom follow-up in Discord and Webex clients send every host through the proxy and ignore NO_PROXY #40249, the pinned guards and the :99999 port guard: fixed, or no longer apply after the re-scope.
  • Telegram NO_PROXY on every platform: still a maintainer decision. It does no harm and fixes a real macOS and Linux gap.

What the review checked on this head:

  • Every WebClient and AsyncWebClient built under src/ now passes proxy=resolve_proxy(SLACK_API_URL). The new source scan goes red if a future client leaves out proxy=.
  • Telegram keeps its loopback check first, so a token-bearing local base never goes through a proxy.
  • The scheme filter applies only to OS-sourced values. An operator's own HTTPS_PROXY passes through unchanged, as on main.
  • website/ and .github/ match main.

What a maintainer still decides:

  • The other change request on this PR (regular expressions in website/electron/system-proxy-env.js) is moot, because that file is no longer in the diff. Its reviewer still has to dismiss it or re-review.
  • The frozen ## Not a goal line says the channel clients are not changed, but this diff changes them. A maintainer accepts the re-scope or amends that line in a PR comment.

Optional:

  • src/kiro_crew/http_proxy.py:40: when HTTPS_PROXY is set and NO_PROXY names slack.com, the Slack Web API clients get proxy=None. slack_sdk then reads HTTPS_PROXY again, and it ignores NO_PROXY. So that leg still uses the proxy while Socket Mode goes direct. This is the same as main. A line under Known limits, or a note on Discord and Webex clients send every host through the proxy and ignore NO_PROXY #40249, would cover it.
  • test/test_slack_client_proxy.py:41: the scan accepts any proxy= value, so proxy=None would stay green at the 8 sites that have no value test. Checking that the value is a resolve_proxy(SLACK_API_URL) call would pin it.
  • The body says only the Slack and Telegram clients change. The SOCKS-only OS filter also affects every other resolve_proxy caller on a Windows host whose only system proxy is SOCKS. Those callers now connect direct where main failed. One line in Backwards compatibility would say so.

@KiroCrewCaptain
KiroCrewCaptain dismissed their stale review November 21, 2026 13:28

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.
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Rebased onto main 0385782 to clear the conflict with #40488, which added http_proxy.proxy_for_url. Telegram now uses that helper, and this PR's duplicate environment-only mode on is_bypassed is gone; the second commit is unchanged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

5 participants