Repository navigation
fix: lead network failures in doctor and the relay pipe with the cause - #34559
Conversation
bolichen97
left a comment
There was a problem hiding this comment.
Approving. The change is small and does what #33901 asks.
cli_doctor.py:network_failure_cause(exc)comes first, and the fallback masks the url's password, query and fragment. That closes thenonnumeric port: 'pass@host'leak beside the redacted url.remote_session/client.py: same cause-first line, and the import stays local to the failed dial.- I ran the touched suites on head
9e02735baf:test/test_cli_stt_memory_doctor.py+test/test_remote_session_client.pygave 58 passed, andtest/test_flake_pattern_ratchet.pygave 68 passed.
One non-blocking nit: _without_url_secrets uses str.replace, so a very short query or fragment (for example ?a) masks every matching substring in the error text. The result is over-masking, never a leak, so it is fine to leave as is.
I'll merge once CI and the review lanes are green.
AI-assisted, sent by CommunityCrew
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: two message sites now reuse the existing type-based [DESIGN-REVIEWED] b41b4e7 Description read[DESCRIPTION-READ] 482c5579ac56937ed39a59f113c217e00922f2bf01d6ab28d8045703afbb93e8 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The change reuses the existing What this change shipsInventory (3 items) — 3 justifiedIntent: a person reading
[FIRST-PRINCIPLES-REVIEWED] b41b4e7 Description read[DESCRIPTION-READ] f23284fcbbeb6f5b8c0ffe0254302546c4130227daa64fc28943ceb2a2cdf262 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
bolichen97
left a comment
There was a problem hiding this comment.
Changing my approval to a change request. The GPT lane's security finding reproduces on head 9e02735baf.
With url = "https://user:pa:hunter2@mirror.example/m.gguf", urlopen raises:
nonnumeric port: 'hunter2@mirror.example'
_without_url_secrets looks for the whole password pa:hunter2, which is not in that text, so the output still shows hunter2. http.client splits the port at the host's last :, so only the tail after it appears.
Suggested fix, in line with the lane's advice: when network_failure_cause(exc) names no cause and the url carries a password (or the url cannot be parsed), print a fixed line such as the model url could not be opened instead of the exception text. Please add a test with a colon in the password.
The relay pipe change and the rest of the doctor change look good to me.
AI-assisted, sent by CommunityCrew
kirocrew doctor's model url probe and the remote workspace's relay pipe printed Python's exception text when a connection failed. Both now lead with the plain cause from network_failure_cause when it names one, and keep today's text otherwise. urllib quotes parts of a malformed url in its error text, so the doctor line could show a password beside the redacted url. When the url carries a password, query or fragment and no cause is named, doctor now prints a fixed line instead of the exception text. Closes kirodotdev#33901
9e02735 to
b41b4e7
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approving head b41b4e7626. _model_url_failure_text now names a known cause first, and otherwise prints the fixed the model url could not be opened for any url that carries a password, query or fragment, or that cannot be parsed. That closes the colon-password leak without masking by value. The new tests cover the colon case with a real urllib error.
I ran test/test_cli_stt_memory_doctor.py + test/test_remote_session_client.py on this head: 63 passed. I'll merge once CI and the review lanes are green.
AI-assisted, sent by CommunityCrew
Problem / Motivation
Goal:
kirocrew doctor's model url probe and the remote relay pipe lead a network failure with its plain cause instead of Python's exception text.#33713 made network failures lead with the cause through
asset_downloader.network_failure_cause. Two user-facing messages it did not cover still print the raw exception:kirocrew doctor:model url: ❌ unreachable (<urlopen error [Errno -2] Name or service not known>) https://...crew-remote: relay unreachable: [Errno 111] Connect call failed ('127.0.0.1', <port>)The doctor line also had a leak. It prints the url through
redact_model_url, but urllib quotes parts of a malformed url in its error text. Withhttps://user:pass@host/...it printednonnumeric port: 'pass@host', showing the password beside the redacted url.Why it matters
A person reading
doctoror a failed remote session sees "connection refused" or "the host name could not be resolved", not an errno. The doctor output no longer shows a password from a private-mirror url.Not a goal
redact_model_urlitself.What changed (motivation → approach → change)
src/kiro_crew/cli_doctor.py: the unreachable line usesnetwork_failure_cause(exc). When it names no cause, the new_model_url_failure_textkeeps the exception text, unless the url carries a password, query or fragment (or cannot be parsed). Then it prints the fixedthe model url could not be opened. Masking the secret by value was not enough: http.client splits the port at the host's last:, so a password with a colon reaches the error text only in part.src/kiro_crew/remote_session/client.py: the relay-unreachable line usesnetwork_failure_cause(exc), else the exception as before. The import is local, so only a failed dial loads the downloader module.Backwards compatibility
Message text only. No config, route, exit code or API changes. A failure with no named cause prints the same text as before, except a doctor url with a password, query or fragment, which prints the fixed line.
Tests
test/test_cli_stt_memory_doctor.py::TestModelUrlUnreachableCause: host not found, connection refused, an unnamed error keeps its text, a url with a password (with and without a colon), query or fragment prints the fixed line, a real urllib error for a colon password is not echoed, and a secret-bearing url still names a known cause.test/test_remote_session_client.py: a refused relay printsconnection refused, and an unnamed dial failure keeps its text.Proof: PROVEN test/test_cli_stt_memory_doctor.py::TestModelUrlUnreachableCause::test_unresolved_host_names_the_cause, test/test_cli_stt_memory_doctor.py::TestModelUrlUnreachableCause::test_refused_connection_names_the_cause, test/test_cli_stt_memory_doctor.py::TestModelUrlUnreachableCause::test_a_secret_bearing_url_never_reaches_the_error_text[password], test/test_cli_stt_memory_doctor.py::TestModelUrlUnreachableCause::test_a_secret_bearing_url_never_reaches_the_error_text[password-with-colon], test/test_cli_stt_memory_doctor.py::TestModelUrlUnreachableCause::test_a_secret_bearing_url_never_reaches_the_error_text[query] (head b41b4e7)
Manual verification
Ran both paths on main before the fix: an unresolvable model url host, a
user:pass@model url, and a relay pipe dialed at a closed loopback port. Each printed the raw text shown above. After the fix they printthe host name could not be resolved,the model url could not be openedandconnection refused. The review'shttps://user:pa:hunter2@mirror.example/m.ggufcase also prints the fixed line, with no part of the password.Related Issues
Closes #33901
Sibling sweep
Swept: git grep -nE "(unreachable|could not reach|could not connect|connection failed)[^"]*{exc}" -- src/
Sibling: src/kiro_crew/memory_forget_client.py:158 -- tracked in #33608
Sibling: src/kiro_crew/coder/session_browse.py:219 -- not affected -- not in this issue's scope; left for a follow-up sweep
Sibling: src/kiro_crew/apps/builtins/mochi/petdex_import.py:242 -- not affected -- not in this issue's scope; left for a follow-up sweep
Sibling: src/kiro_crew/apps/builtins/dev_fleet/pointer_broker.py:94 -- not affected -- loopback gateway route error, not in this issue's scope
Sibling: src/kiro_crew/apps/builtins/design_tweak/backend/dev_preview.py:568 -- not affected -- HTTP 502 body for a local dev server, not in this issue's scope
Pattern harvest
Rule candidate: semgrep
Pattern: an f-string that prints a caught network exception's text as the failure reason without
network_failure_causeChecklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement