Skip to content

fix(windows): bootstrap UTF-8 before running gateway task script#43975

Open
stim64045-spec wants to merge 1 commit intoopenclaw:mainfrom
stim64045-spec:fix/issue-43943
Open

fix(windows): bootstrap UTF-8 before running gateway task script#43975
stim64045-spec wants to merge 1 commit intoopenclaw:mainfrom
stim64045-spec:fix/issue-43943

Conversation

@stim64045-spec
Copy link
Copy Markdown
Contributor

@stim64045-spec stim64045-spec commented Mar 12, 2026

Summary

  • prepend chcp 65001>nul to generated Windows gateway task scripts so cmd.exe reads non-ASCII paths correctly
  • teach scheduled-task command parsing to ignore the UTF-8 bootstrap line
  • add regression coverage for Chinese-path task scripts

Testing

  • pnpm exec vitest run --config vitest.unit.config.ts src/daemon/schtasks.install.test.ts src/daemon/schtasks.test.ts src/daemon/cmd-argv.test.ts
  • pnpm exec oxfmt --check src/daemon/schtasks.ts src/daemon/schtasks.install.test.ts src/daemon/schtasks.test.ts

Closes #43943

@openclaw-barnacle openclaw-barnacle bot added gateway Gateway runtime size: S labels Mar 12, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 12, 2026

Greptile Summary

This PR fixes a UTF-8 encoding issue on Windows by prepending chcp 65001>nul to the generated gateway task scripts, enabling cmd.exe to correctly handle non-ASCII characters (e.g., Chinese) in paths, environment variables, and arguments. A companion change teaches readScheduledTaskCommand to skip this bootstrap line during parsing, maintaining round-trip fidelity. Tests are added to cover both sides: script generation with Chinese-character paths and parser skipping of the bootstrap line.

Changes:

  • schtasks.ts: buildTaskScript now initialises lines with ["@echo off", "chcp 65001>nul"]; new isCmdUtf8BootstrapLine regex helper (case-insensitive, handles optional @ prefix, .com/.exe extension, and >nul redirect) is wired into readScheduledTaskCommand to skip the line during parsing.
  • schtasks.install.test.ts: Existing test gets a toContain("chcp 65001>nul") assertion; new end-to-end test covers a full install + read-back cycle with Chinese-character paths and environment variables.
  • schtasks.test.ts: New unit test directly exercises readScheduledTaskCommand with a script that includes the bootstrap line, verifying it is skipped correctly.

Confidence Score: 5/5

  • This PR is safe to merge — the change is minimal, well-scoped, and thoroughly tested.
  • The implementation is a targeted two-line change to script generation and a corresponding parser guard. The regex in isCmdUtf8BootstrapLine is correct and not susceptible to ReDoS. Tests cover generation ordering (CRLF), round-trip parsing, and the parser-only path with a Chinese-character fixture. No existing behaviour is broken.
  • No files require special attention.

Last reviewed commit: 6a83a9b

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

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [Windows] Gateway fails to start with Chinese username path

1 participant