Skip to content

fix: add encoding='utf-8' to subprocess calls with text=True - #53549

Closed
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/subprocess-encoding-windows
Closed

fix: add encoding='utf-8' to subprocess calls with text=True#53549
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/subprocess-encoding-windows

Conversation

@AlexFucuson9

Copy link
Copy Markdown
Contributor

Bug

On non-UTF-8 Windows locales (e.g. CP936/GBK), subprocess.run/Popen with text=True but no explicit encoding crashes _readerthread when child outputs UTF-8 text:

UnicodeDecodeError: 'gbk' codec can't decode byte 0xae

This triggers cascading failure: pipe buffers fill → event loop stalls → ws write slow → TUI freezes → gateway restarts.

Fix

Add encoding='utf-8', errors='replace' to all 22 bare text=True subprocess calls across 13 files:

  • tui_gateway/server.py (4)
  • tui_gateway/git_probe.py (1)
  • agent/lsp/install.py (3)
  • agent/anthropic_adapter.py (2)
  • agent/context_references.py (2)
  • agent/secret_sources/bitwarden.py (2)
  • agent/copilot_acp_client.py (1)
  • agent/skill_preprocessing.py (1)
  • agent/coding_context.py (1)
  • agent/transports/codex_app_server.py (1)
  • agent/shell_hooks.py (1)
  • gateway/status.py (2)
  • gateway/shutdown_forensics.py (1)

Fixes #53428

On non-UTF-8 Windows locales (e.g. CP936/GBK), subprocess.run/Popen
with text=True but no explicit encoding crashes _readerthread when
child outputs UTF-8 text:

  UnicodeDecodeError: 'gbk' codec can't decode byte 0xae

This triggers cascading failure: pipe buffers fill → event loop stalls
→ ws write slow → TUI freezes → gateway restarts.

Fix by adding encoding='utf-8', errors='replace' to all 22 bare
text=True subprocess calls across 13 files.

Fixes NousResearch#53428
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows P2 Medium — degraded but workaround exists labels Jun 27, 2026
@AlexFucuson9 AlexFucuson9 reopened this Jun 28, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by the consolidated Windows console-flash work tracked in #54220.

The relevant pieces from this PR/cluster have now landed through the targeted follow-up PRs #54236, #53892, and #54417, or are recorded in the umbrella tracker for any remaining native-Windows verification. Keeping this separate PR open would duplicate the tracker and the merged follow-up work.

Thanks for digging into this — the reports and PRs in this cluster helped identify the remaining spawn legs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

subprocess.run(text=True) without encoding param triggers GBK crash on Chinese Windows (21 locations)

3 participants