Skip to content

test(mcp): pin utf-8 on the test_mcp_api_port_resolution subprocess call - #20135

Merged
javenciu merged 1 commit into
mainfrom
test/subprocess-encoding-mcp-api-port-resolution
Oct 14, 2026
Merged

javenciu merged 1 commit into
mainfrom
test/subprocess-encoding-mcp-api-port-resolution

Conversation

@javenciu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Pin the output decoding of the one child-interpreter call in test/test_mcp_api_port_resolution.py to UTF-8 and take that file off the subprocess-encoding baseline.

A text-mode subprocess.run with no encoding= 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.py records every pre-existing offender in .github/subprocess-encoding-baseline.txt as <count> <path> and lets the counts only shrink. test/test_mcp_api_port_resolution.py:277 is one of them: TestPortResolutionStaysLeaf.test_import_does_not_pull_cli_server runs [sys.executable, "-c", code] with capture_output=True, text=True and no encoding=, and the file is listed as 1 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

  • No change to what the test asserts, to the probe code, or to any other call: this file holds exactly one spawn primitive (line 277), and the other files on the baseline stay as they are.
  • No errors= setting: decoding keeps the default strict handling.
  • No use of the shared UTF8_TEXT mapping: it carries text=True, which this call already passes, so splatting it would pass text twice. Plain encoding="utf-8" is the form test/test_check_feed_advance.py and test/test_cron_script.py already 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 for text=True and names no encoding. Change:

  • test/test_mcp_api_port_resolution.py: add encoding="utf-8", to the subprocess.run( call that starts at line 277, directly after text=True, (the new line is 282).
  • .github/subprocess-encoding-baseline.txt: delete the line 1 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

  • RED: with the baseline line deleted and the test file untouched, RATCHET_SCOPE_WHOLE_TREE=1 python3 scripts/check_subprocess_encoding.py exits 1 with 1 new offender(s) at test/test_mcp_api_port_resolution.py:277.
  • GREEN: with the edit and the baseline line removed, python3 scripts/check_subprocess_encoding.py --test exits 0 (9 flagged probes, 9 clean probes), and python3 scripts/check_subprocess_encoding.py exits 0 both on the committed change (scope origin/main...HEAD, 2 changed files) and with RATCHET_SCOPE_WHOLE_TREE=1.
  • pytest test/test_mcp_api_port_resolution.py -q -n0: 18 passed before the edit, 18 passed after.
  • Leak check: that file first, then test/test_taskrunner_atomic_persistence.py and test/test_wheel_apply.py, in one process at -n0: 78 passed.
  • flake8 on the touched file exits 0, and GITHUB_BASE_REF=main python3 scripts/check_black_formatting.py exits 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

  • 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.

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.
@javenciu
javenciu requested review from a team and KiroCrewCaptain as code owners October 14, 2026 05:22
@javenciu
javenciu requested a review from mbriones98 October 14, 2026 05:23
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision eddfd0648d942d3abbcaa9936878778a0a52f39c ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision eddfd0648d942d3abbcaa9936878778a0a52f39c touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of eddfd0648d942d3abbcaa9936878778a0a52f39c — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .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 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed eddfd0648d942d3abbcaa9936878778a0a52f39c — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] eddfd06

Verdict parsed from the review's SHA-scoped output markers for commit eddfd0648d942d3abbcaa9936878778a0a52f39c.

False positive or not applicable? A repository writer can comment:
/ai-review override fable eddfd0648d942d3abbcaa9936878778a0a52f39c: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of eddfd0648d942d3abbcaa9936878778a0a52f39c and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] eddfd06

False positive or not applicable? A repository writer can comment:
/ai-review override gpt eddfd0648d942d3abbcaa9936878778a0a52f39c: <one-sentence reason>

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 14, 2026
@javenciu

Copy link
Copy Markdown
Contributor Author

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).

@javenciu javenciu closed this Oct 14, 2026
@javenciu javenciu reopened this Oct 14, 2026
@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 Oct 14, 2026
@javenciu
javenciu enabled auto-merge (squash) October 14, 2026 08:48

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@javenciu
javenciu merged commit 91860fd into main Oct 14, 2026
112 of 174 checks passed
@javenciu
javenciu deleted the test/subprocess-encoding-mcp-api-port-resolution branch October 14, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants