Skip to content

fix(gateway_windows): handle non-UTF-8 schtasks output on localized Windows - #24478

Closed
fatinghenji wants to merge 1 commit into
NousResearch:mainfrom
fatinghenji:fix/windows-schtasks-encoding
Closed

fix(gateway_windows): handle non-UTF-8 schtasks output on localized Windows#24478
fatinghenji wants to merge 1 commit into
NousResearch:mainfrom
fatinghenji:fix/windows-schtasks-encoding

Conversation

@fatinghenji

Copy link
Copy Markdown
Contributor

Problem

On Chinese Windows (and other non-English locales), schtasks.exe outputs status/error messages in the system code page (e.g. GBK). subprocess.run() with text=True defaults to UTF-8 decoding, causing UnicodeDecodeError when the CLI tries to parse schtasks output.

This breaks all hermes gateway commands on localized Windows systems:

  • hermes gateway status
  • hermes gateway start
  • hermes gateway stop
  • hermes gateway install
  • hermes gateway uninstall

Error

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 2: invalid continuation byte

Fix

Add encoding="utf-8" with errors="replace" to _exec_schtasks() in gateway_windows.py. This gracefully handles mixed-encoding output from schtasks by replacing undecodable bytes with replacement characters instead of crashing.

Testing

  • Verified on Windows 11 Pro (Chinese locale) — hermes gateway status now works without UnicodeDecodeError
  • hermes gateway start/stop commands functional after fix
  • Gateway service installs and runs correctly

Related

Fixes encoding issue affecting all Windows users with non-English system locales.

…indows

On Chinese Windows (and other non-English locales), schtasks.exe outputs
status/error messages in the system code page (e.g. GBK). subprocess.run()
with text=True defaults to UTF-8 decoding, causing UnicodeDecodeError when
the CLI tries to parse schtasks output.

Add encoding="utf-8" with errors="replace" to gracefully handle mixed-
encoding output from schtasks, allowing gateway status/start/stop/install
commands to work correctly on localized Windows systems.

Fixes: UnicodeDecodeError when running hermes gateway commands on Chinese Windows
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels May 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with #24417 which addresses the same schtasks UnicodeDecodeError but uses encoding=mbcs (system ANSI code page). This PR uses encoding=utf-8 with errors=replace. Note #24417 is a bundled PR that also includes QQBot and MEDIA fixes — this PR is scoped narrowly to just the schtasks encoding issue.

tcflying added a commit to tcflying/hermes-agent-windows-rust-old that referenced this pull request May 15, 2026
- psutil-based process start time fallback (NousResearch#25502)
- ConPTY Bridge for native Windows terminal support
- prompt_toolkit Vt100 output fallback for Git Bash
- Git Bash path resolution (/d/path -> D:\path)
- UTF-8 encoding for subprocess calls (doctor, schtasks)
- Bash forward slashes in cron scripts (NousResearch#23404)
- schtasks mbcs encoding for non-ASCII task names (NousResearch#24417, NousResearch#24478)
- __main__.py launcher for python -m hermes_cli (NousResearch#21465)
- shutdown_forensics Windows process snapshot
- Comprehensive E2E test suite with 23 tests

Fixes Windows native installation without WSL2 requirement.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@teknium1

Copy link
Copy Markdown
Contributor

Automated hermes-sweeper review: this schtasks UnicodeDecodeError fix is already implemented on current main.

Evidence:

  • hermes_cli/gateway_windows.py:56 now defines _schtasks_encoding(), using locale.getpreferredencoding(False) with a UTF-8 fallback for localized Windows schtasks output.
  • hermes_cli/gateway_windows.py:126 passes encoding=_schtasks_encoding() and errors="replace" to subprocess.run() inside _exec_schtasks(), so non-UTF-8 schtasks output no longer crashes subprocess text decoding.
  • _exec_schtasks() is the shared wrapper used by gateway install/delete/create, status/query, start/run, and stop/end paths, covering the commands listed in this PR.
  • The implementing commit is 973decc05048f1d6fe990d5d6457e80389d5f1c5 (fix(gateway): decode schtasks output with locale encoding on Windows), contained in v2026.6.5.

The current implementation uses locale decoding plus replacement rather than forced UTF-8 replacement, which better matches the localized Windows behavior discussed in the PR thread.

@teknium1 teknium1 closed this Jun 11, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants