Skip to content

[codex] Handle PowerShell UTF-8 setup failures#24949

Merged
iceweasel-oai merged 1 commit into
mainfrom
codex/powershell-utf8-best-effort
May 28, 2026
Merged

[codex] Handle PowerShell UTF-8 setup failures#24949
iceweasel-oai merged 1 commit into
mainfrom
codex/powershell-utf8-best-effort

Conversation

@iceweasel-oai
Copy link
Copy Markdown
Collaborator

Fixes #12496.

Why

Windows sandboxed PowerShell commands can run under ConstrainedLanguage on some machines, especially enterprise-managed Windows environments. In that mode, our PowerShell command prelude could fail before every command because it directly assigned [Console]::OutputEncoding to UTF-8. The actual user command still ran, but Codex surfaced noisy Cannot set property. Property setting is supported only on core types in this language mode. output for every shell call.

What Changed

  • Makes the PowerShell UTF-8 output encoding prelude best-effort by wrapping the assignment in try { ... } catch {}.
  • Keeps the existing UTF-8 behavior when PowerShell allows the assignment.
  • Adds focused tests for adding the prelude and avoiding duplicate prelude insertion.

Validation

  • cargo fmt -p codex-shell-command
  • cargo check -p codex-shell-command
  • git diff --check
  • Verified a local ConstrainedLanguage PowerShell probe prints only the command output with no property-setting error.
  • Verified codex exec from a temporary chcp 437 context reports utf-8 / 65001 and preserves non-ASCII output (café, 漢字).

@iceweasel-oai iceweasel-oai marked this pull request as ready for review May 28, 2026 18:55
@iceweasel-oai iceweasel-oai enabled auto-merge (squash) May 28, 2026 19:00
@iceweasel-oai iceweasel-oai merged commit d9f5312 into main May 28, 2026
47 of 49 checks passed
@iceweasel-oai iceweasel-oai deleted the codex/powershell-utf8-best-effort branch May 28, 2026 20:58
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerShell error when Codex is running shell commands in a sandbox

2 participants