Skip to content

fix(cli): decode redirected Windows input as UTF-8 - #754

Open
rudycelekli wants to merge 1 commit into
Panniantong:mainfrom
rudycelekli:fix/agent-reach-windows-stdin-20261002
Open

rudycelekli wants to merge 1 commit into
Panniantong:mainfrom
rudycelekli:fix/agent-reach-windows-stdin-20261002

Conversation

@rudycelekli

Copy link
Copy Markdown

Problem

Windows Python can decode redirected stdin with an ANSI code page, while upstream tools emit UTF-8 JSON. The CLI currently changes stdout/stderr to UTF-8 but leaves stdin unchanged. A Chinese XHS title therefore becomes mojibake through agent-reach format xhs, even though parsing succeeds.

Changes

  • Reconfigure redirected Windows stdin to strict UTF-8 before reading it.
  • Preserve interactive console input, text-only streams and the existing pytest capture guard.
  • Report invalid UTF-8 as a clear format error with a failing exit status.

Verification

  • Native child processes with raw UTF-8 stdin and PYTHONIOENCODING=cp1252, using a simulated Windows platform: unchanged main produces corrupted title/description.
  • Focused regressions: unchanged main 2 failures and 3 controls; fixed branch 5 pass.
  • Full test suite: 612 passed; Ruff and diff whitespace checks pass.
  • Native Windows was not run; the code-page boundary is reproduced in real subprocesses on macOS with a simulated platform flag.
  • MyPy retains unchanged-main MCP SDK v2 errors; this change adds none.

AI-assisted implementation and tests, independently reviewed before submission.

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant