Repository navigation
test(mcp): pin utf-8 on the test_mcp_api_port_resolution subprocess call - #20135
Conversation
The leaf-import probe in test_mcp_api_port_resolution.py runs a child interpreter in text mode with no encoding, so the captured output is decoded with the locale code page (mojibake on Windows). Pin encoding="utf-8" on that call and drop the file's entry from .github/subprocess-encoding-baseline.txt so the ratchet list shrinks.
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] eddfd06 Description read[DESCRIPTION-READ] 5649a167966e34bc17890eb5f54c3b7d63f5f0ac3662704664c380280e548991 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 |
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: |
|
Closing and reopening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683). |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: pins utf-8 on one test subprocess call and drops its line from the encoding baseline.
Problem / Motivation
Goal: Pin the output decoding of the one child-interpreter call in
test/test_mcp_api_port_resolution.pyto UTF-8 and take that file off the subprocess-encoding baseline.A text-mode
subprocess.runwith noencoding=decodes the child's output with the locale's code page: effectively UTF-8 on POSIX, the legacy ANSI page on Windows, where a non-ASCII byte comes back as mojibake (the class #5249 added the gate for).scripts/check_subprocess_encoding.pyrecords every pre-existing offender in.github/subprocess-encoding-baseline.txtas<count> <path>and lets the counts only shrink.test/test_mcp_api_port_resolution.py:277is one of them:TestPortResolutionStaysLeaf.test_import_does_not_pull_cli_serverruns[sys.executable, "-c", code]withcapture_output=True, text=Trueand noencoding=, and the file is listed as1 test/test_mcp_api_port_resolution.py.Why it matters
The gate treats an unpinned text-mode call as a defect and only grandfathers the existing ones, so each pinned call that leaves the baseline moves the list toward empty. The text decoded here is
proc.stderr, which is the message of the assertion at line 285, so it is what a developer reads when the probe fails on a Windows runner.Not a goal
errors=setting: decoding keeps the default strict handling.UTF8_TEXTmapping: it carriestext=True, which this call already passes, so splatting it would passtexttwice. Plainencoding="utf-8"is the formtest/test_check_feed_advance.pyandtest/test_cron_script.pyalready use for a text-mode run.What changed (motivation → approach → change)
Symptom: the baseline lists the call as an unpinned text-mode
subprocess.run. Cause: the call asks fortext=Trueand names no encoding. Change:test/test_mcp_api_port_resolution.py: addencoding="utf-8",to thesubprocess.run(call that starts at line 277, directly aftertext=True,(the new line is 282)..github/subprocess-encoding-baseline.txt: delete the line1 test/test_mcp_api_port_resolution.py.Two files, one line added and one removed. Nothing else changes.
Backwards compatibility
Removes nothing: a test-only change; no production code, public API or protocol is modified.
Tests
RATCHET_SCOPE_WHOLE_TREE=1 python3 scripts/check_subprocess_encoding.pyexits 1 with1 new offender(s)attest/test_mcp_api_port_resolution.py:277.python3 scripts/check_subprocess_encoding.py --testexits 0 (9 flagged probes, 9 clean probes), andpython3 scripts/check_subprocess_encoding.pyexits 0 both on the committed change (scopeorigin/main...HEAD, 2 changed files) and withRATCHET_SCOPE_WHOLE_TREE=1.pytest test/test_mcp_api_port_resolution.py -q -n0: 18 passed before the edit, 18 passed after.test/test_taskrunner_atomic_persistence.pyandtest/test_wheel_apply.py, in one process at-n0: 78 passed.flake8on the touched file exits 0, andGITHUB_BASE_REF=main python3 scripts/check_black_formatting.pyexits 0 (2 changed files, 1 checked).Manual verification
N/A: one keyword argument on a test's subprocess call; the gate and test runs above cover it.
Screenshots / video
N/A: no user-visible UI change.
Related Issues
No issue exists; burn-down of the subprocess-encoding baseline (precedents: the gate's own PR #5378, and the baseline-shrinking fixes #14648 and #14664).
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.