Repository navigation
fix(kas-auth): send sign-in and renewal through the proxy - #36978
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: sign-in and renewal now reuse the existing Notes
[DESIGN-REVIEWED] ab71238 Description read[DESCRIPTION-READ] 011e53033e1eabc01f5e62a94ad1fe53343cec894fe9cc42df37e1f38f3a27c9 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS One stray re-export is the only surplus. It is small and private, so it does not block. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: on a network that reaches Kiro only through a proxy, sign-in and token renewal work, and a proxy's refusal is reported as a proxy problem. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] ab71238 Description read[DESCRIPTION-READ] de2dbb0c8d4f54e13d1f077bfea106956e239cfe9a7e2e668e45e85aa7a34535 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
bolichen97
left a comment
There was a problem hiding this comment.
Thanks. I read the whole diff on this head, and all checks are green. Most of it is good to keep:
- Every sign-in and renewal request now passes
proxy=resolve_proxy(url), the shared helper on main (http_proxy.resolve_proxy). With no proxy configured it returnsNone, which is aiohttp's own default, so a host without a proxy sends exactly what main sends.NO_PROXYhosts go direct,trust_envstays off (no~/.netrc), and the tests cover each of the twelve request sites both ways. - Nothing new is logged. No log line is added, the refresh token and codes still travel only in the request bodies, and the existing log lines are untouched.
- The temporary session
KasAuthProvideropens now uses the same 30s / 10sHTTP_TIMEOUTthe login service's shared session already used on main, moved torefresh.pyso both read one constant. - A proxy's own refusal now reads as a network error, not a sign-out. A bare
status code 403and a named service exception keep their sign-in verdict, and the tests check both.
I am requesting changes on one point: new regex in product code. The new acp/proxy_refusal.py adds _RE_PROXY_NAMED and _RE_PROXY_REFUSED (re.compile), used by _proxy_refusal_line and so by _is_session_expired, classify_provider_error and the chat wording. Product code takes no new regex. The same per-line test works with plain string checks on line.lower():
- the proxy is named: the line holds the word
proxy,tunnelortunneling, orCONNECT(case-sensitive), checked as whole words by splitting on non-letters; - and it refuses: the line holds
401,403or407as a whole token, or one of the phrasesauthentication required,authorization required,tunnel error,tunnel failed,tunneling failed,could not be established, or!== 200.
The behaviour, tests and chat text can stay as they are. I will approve once proxy_refusal.py has no re import.
75e6dc5 to
a2abab2
Compare
|
Thanks @bolichen97. Done in a2abab2:
Behaviour, tests and chat text are unchanged. The 18 test files that cover the classifier, the auth flows and the proxy paths pass 1056/1056 on 3 runs and on 1 shuffled run, and black, flake8 and |
Code change approver recommendation: A person should decideWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 483 lines, more than the 400 it may approve on its own. I'd approve this head as it stands; I found nothing that blocks it. Sign-in and renewal through the proxy. I listed every outbound request under
Timeout move. Proxy refusals. The new check applies per line, only to lines that name the proxy, a tunnel or
Named service exceptions such as An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
Kiro Crew's own requests to the sign-in service ignored HTTPS_PROXY, HTTP_PROXY and NO_PROXY, so on a proxy-only network a renewal failed and the chat said 'Not signed in to Kiro'. Every sign-in and refresh request now passes resolve_proxy(url), with trust_env still off (no netrc), and the temporary renewal session is bounded to 30 s. An engine line that names the proxy, its tunnel or CONNECT and carries a refusal is now a connection error with a proxy message, not a sign-in failure. A bare 403 keeps its signed-out verdict. Closes #36954
a2abab2 to
ab71238
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at ab71238. The change I asked for is in place, so I'm approving.
acp/proxy_refusal.pyno longer has_RE_PROXY_NAMEDor_RE_PROXY_REFUSED, and the change has noimport re,re.compileor otherre.call._names_proxysplits the line into letter runs and checks forCONNECT(case-sensitive) orproxy/tunnel/tunnelingas whole words._refuseschecks for401/403/407as whole alphanumeric tokens, or one of the fixed phrases online.lower(). That's the same per-line test as before.- Compared with 75e6dc5, which I reviewed in full, this is the only change. Every sign-in and renewal request still passes
proxy=resolve_proxy(url), withtrust_envoff and the sharedHTTP_TIMEOUT. A barestatus code 403keeps its sign-in verdict, and only a line that names the proxy reads as a network error. - It adds no refusal. A proxy refusal now goes to the connection class and the bounded retry, where main read it as a terminal sign-out.
All checks are green. Approving. Auto-merge is left as you set it.
Kiro Crew's own requests to the sign-in service ignored HTTPS_PROXY, HTTP_PROXY and NO_PROXY, so on a proxy-only network a renewal failed and the chat said 'Not signed in to Kiro'. Every sign-in and refresh request now passes resolve_proxy(url), with trust_env still off (no netrc), and the temporary renewal session is bounded to 30 s. An engine line that names the proxy, its tunnel or CONNECT and carries a refusal is now a connection error with a proxy message, not a sign-in failure. A bare 403 keeps its signed-out verdict. Closes #36954 (cherry picked from commit c8f45fb)
Problem / Motivation
Goal: On a network that reaches Kiro only through an HTTP(S) proxy, Kiro Crew's sign-in and token renewal go through that proxy, and a proxy's own refusal says the proxy blocked it instead of "Not signed in to Kiro".
Two gaps on
main, tracked in #36954:proxy=, and their sessions keeptrust_envoff on purpose. SoHTTPS_PROXY/HTTP_PROXY/NO_PROXYwere never read, while kiro-cli follows them. A renewal that could not reach the issuer reached the engine as a failed refresh, and the chat said "Not signed in to Kiro".Why it matters
Not a goal
status code 403with no proxy word apart from Kiro's own 403: that line keeps its signed-out verdict.trust_envstays off, so~/.netrcis never read.What changed (motivation → approach → change)
kiro_crew/auth/)proxy=resolve_proxy(url)from the existinghttp_proxy.py, which readsHTTPS_PROXY/HTTP_PROXYand honoursNO_PROXYauth/refresh.py,auth/provider.py,auth/service.py)refresh.HTTP_TIMEOUT; the temporary renewal session uses it instead of aiohttp's five-minute defaultacp/proxy_refusal.py,acp/transport_errors.py)CONNECTand carries a refusal (401/403/407, "authentication required", tunnel error, "could not be established",!== 200) is dropped before the sign-in check, classified as a connection error, and shown as "A network proxy blocked the request to the model backend…"kas-auth.md)The proxy helpers live in a new
acp/proxy_refusal.py, re-exported bytransport_errors.py, which keeps that file under the 2,000-line cap.This builds on the approach of #31966 by okajun35 (the same
resolve_proxyrouting for sign-in and refresh), which has had a merge conflict with main since 2026-11-10. It is rewritten fresh on current main, with the proxy-refusal half added.builder-security checked: the change only alters the route of outbound HTTPS requests. It adds no listener and weakens no auth. The proxy comes from the operator's own environment, and the sign-in URLs are
https://, so the proxy carries aCONNECTtunnel and cannot read the tokens.Backwards compatibility
Compatible: with no proxy variables set,
resolve_proxyreturnsNoneand every request is sent exactly as before; only engine lines that name a proxy change class.Removes nothing: no key, route or function is removed; the timeout constant moves from
service.pytorefresh.py, and both readers import it from there.Tests
Proof: PROVEN test/test_acp_auth_failure_on_stderr.py::test_a_proxy_refusal_is_a_network_error_not_a_sign_in_failure[HTTP status client error (407 Proxy Authentication Required) for url (https://q.example/)], test/test_acp_auth_failure_on_stderr.py::test_a_proxy_refusal_is_a_network_error_not_a_sign_in_failure[Received HTTP code 403 from proxy after CONNECT], test/test_acp_auth_failure_on_stderr.py::test_a_proxy_refusal_is_a_network_error_not_a_sign_in_failure[proxy returned HTTP 403 Forbidden], test/test_acp_auth_failure_on_stderr.py::test_a_proxy_refusal_does_not_set_the_signed_out_latch, test/test_acp_auth_failure_on_stderr.py::test_a_proxy_refusal_frame_names_the_proxy_not_the_sign_in (head 75e6dc5)
test/test_kas_auth_proxy.py: 12 request sites × 2 cases. WithHTTPS_PROXYset each request carries that proxy; with its host inNO_PROXYit carriesproxy=None. Also the login service's poll uses the proxy, and the renewal session has a timeout of at most 30 s withtrust_envoff.test/test_acp_auth_failure_on_stderr.py: three proxy lines are not auth failures and classify asconnection; the signed-out latch stays off when it reads them; a Kiro 403, a namedAccessDeniedExceptionand a real sign-in line beside a proxy line still read as signed out; the error frame names the proxy and not the sign-in.proxy=None.test_flake_pattern_ratchet.pyandtest_wait_discipline_ratchet.pypass with-n0.Manual verification
N/A — no end-to-end run through a real proxy; request routing is pinned with fake sessions, and the engine wording comes from the HTTP stacks' own strings (reqwest/hyper's in the kiro-cli binary, curl's, undici's), since no captured engine log from a proxy refusal exists.
Related Issues
Closes #36954
Part of #32425
Sibling sweep
Swept: git grep -nE "session.(post|get)(" -- src/kiro_crew/auth/
Sibling: src/kiro_crew/auth/login/builder_id.py -- changed here
Sibling: src/kiro_crew/auth/login/device.py -- changed here
Sibling: src/kiro_crew/auth/login/portal.py -- changed here
Sibling: src/kiro_crew/auth/login/external_idp.py -- changed here
Sibling: src/kiro_crew/auth/login/control_plane.py -- changed here
Sibling: src/kiro_crew/auth/refresh.py -- changed here
Sibling: src/kiro_crew/auth/service.py -- changed here
Sibling: src/kiro_crew/dashboard/sign_in_refresher.py -- not affected -- its requests go through refresh.ensure_fresh, covered here
Pattern harvest
Rule candidate: semgrep
Pattern: an outbound aiohttp request on a session with trust_env off that passes no proxy=, which silently ignores the proxy environment
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement