You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows systems using a CJK locale, subprocess.Popen(..., text=True) defaults to the system code page (for example GBK). _SlashWorker reads UTF-8 output from the slash-worker subprocess without an explicit encoding, so undecodable bytes can raise UnicodeDecodeError in the stderr-draining daemon thread and take down the gateway.
The worker now explicitly decodes stdout/stderr as UTF-8 and replaces malformed bytes, preserving the gateway process while retaining diagnostic output.
🐛 Bug fix (non-breaking change that fixes an issue)
✨ New feature (non-breaking change that adds functionality)
🔒 Security fix
📝 Documentation update
✅ Tests (adding or improving test coverage)
♻️ Refactor (no behavior change)
🎯 New skill (bundled or hub)
Changes Made
tui_gateway/server.py
Set encoding="utf-8" and errors="replace" on the persistent _SlashWorker subprocess.
tests/test_windows_subprocess_no_window_flags.py
Added a regression test that locks the subprocess stream decoding contract.
How to Test
The reported failure mechanism was reproduced on Linux by simulating the Windows GBK locale: decoding UTF-8 subprocess bytes containing 0xAA with gbk raised UnicodeDecodeError.
Run the focused Windows subprocess contract tests:
My PR contains only changes related to this fix/feature
I've run pytest tests/ -q and all tests pass — focused suites were run; the full suite was not run
I've added tests for my changes
I've tested on my platform: CachyOS Linux; Windows-specific behavior was validated by a GBK decoding reproduction and subprocess contract test
Documentation & Housekeeping
I've updated relevant documentation — N/A; this is an internal subprocess encoding fix
I've updated cli-config.yaml.example — N/A; no config keys changed
I've updated CONTRIBUTING.md or AGENTS.md — N/A; architecture/workflow unchanged
I've considered cross-platform impact; UTF-8 is explicit on all platforms and errors="replace" prevents malformed diagnostics from terminating the reader
I've updated tool descriptions/schemas — N/A; no tool behavior/schema changed
For New Skills
N/A — this PR does not add a skill.
Screenshots / Logs
Not applicable. The focused tests and gateway regression suite pass; the simulated Windows-locale reproduction produced the reported UnicodeDecodeError before the fix path was applied.
Thanks for the focused Windows compatibility fix. The current _SlashWorker spawn uses text=True without an explicit codec at tui_gateway/server.py:314-325, while its daemon readers consume both pipe streams at tui_gateway/server.py:329-340. The worker emits JSON-line responses on stdout at tui_gateway/slash_worker.py:169; specifying UTF-8 with replacement handling at the parent pipe boundary is correct and preserves diagnostics.
The only text-mode Popen stream-reader in tui_gateway/ is this _SlashWorker path. The added regression assertion covers the exact Popen contract. No problems found.
Closing as resolved by PR #70850 (merged, commit ead23aa), which hardened the slash-worker Popen (and every other text=True capture site in the desktop/TUI backend) with encoding="utf-8", errors="replace". Credit for the earliest version of this fix goes to @devorun (#52700) and @Sahil-SS9 (#61978, cherry-picked as the base). Thanks for the fix and test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
area/streamingStreaming responses: gateway delivery, provider wirecomp/tuiTerminal UI (ui-tui/ + tui_gateway/)P2Medium — degraded but workaround existsplatform/windowsNative Windows-specific behavior or breakagesweeper:blast-moderateSweeper blast radius: moderate — a subsystem or single platformsweeper:risk-platform-windowsSweeper risk: may break or behave differently on native Windowstype/bugSomething isn't working
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #63686.
On Windows systems using a CJK locale,
subprocess.Popen(..., text=True)defaults to the system code page (for example GBK)._SlashWorkerreads UTF-8 output from the slash-worker subprocess without an explicit encoding, so undecodable bytes can raiseUnicodeDecodeErrorin the stderr-draining daemon thread and take down the gateway.The worker now explicitly decodes stdout/stderr as UTF-8 and replaces malformed bytes, preserving the gateway process while retaining diagnostic output.
Related Issue
Fixes #63686
Type of Change
Changes Made
tui_gateway/server.pyencoding="utf-8"anderrors="replace"on the persistent_SlashWorkersubprocess.tests/test_windows_subprocess_no_window_flags.pyHow to Test
0xAAwithgbkraisedUnicodeDecodeError.Checklist
Code
fix(scope):,feat(scope):, etc.)_SlashWorkerencoding.pytest tests/ -qand all tests pass — focused suites were run; the full suite was not runDocumentation & Housekeeping
cli-config.yaml.example— N/A; no config keys changedCONTRIBUTING.mdorAGENTS.md— N/A; architecture/workflow unchangederrors="replace"prevents malformed diagnostics from terminating the readerFor New Skills
N/A — this PR does not add a skill.
Screenshots / Logs
Not applicable. The focused tests and gateway regression suite pass; the simulated Windows-locale reproduction produced the reported
UnicodeDecodeErrorbefore the fix path was applied.