Skip to content

fix(extensions): preserve subprocess errors for non-UTF8 stderr - #5186

Merged
seratch merged 1 commit into
mainfrom
codex/fix-codex-stderr-5185
Sep 27, 2026
Merged

seratch merged 1 commit into
mainfrom
codex/fix-codex-stderr-5185

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Collaborator

This pull request fixes Codex subprocess error reporting when stderr contains non-UTF-8 bytes, as reported for the Windows npm shim in #5185.

Summary

Decode stderr with replacement on nonzero exit so callers receive RuntimeError with the exit code and readable diagnostic text instead of UnicodeDecodeError. Valid UTF-8 diagnostics remain intact; undecodable bytes become replacement characters.

The regression uses the captured CP950 diagnostic from #5185 through both Thread.run() and Thread.run_streamed(), with ASCII and UTF-8 controls. Scope is limited to failure stderr decoding.

Test plan

  • Confirmed the two new CP950 cases fail against v0.22.3 with the reported UnicodeDecodeError.
  • All 55 focused Codex execution/thread tests pass with the fix.
  • Real-subprocess replay of captured CP950, ASCII, and UTF-8 stderr passes through both public methods on macOS. Native Windows shim execution was not independently reproduced.
  • Full repository verification passed: formatting, lint, Mypy, Pyright, parallel tests, and serial tests. Native macOS sandbox tests are skipped locally under the prescribed Codex sandbox setting and run separately in CI.
  • Independent review of the complete diff found no actionable issues.

Issue number

Closes #5185

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@jbeckwith-oai
jbeckwith-oai requested review from a team, rm-openai and seratch as code owners September 27, 2026 16:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T16:44:00.772330Z 450788d PR opened
🔒 Security Review ✅ Completed 2026-09-27T16:44:56.507304Z 450788d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@markstuart-oai markstuart-oai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 450788d3d5c0d585a37b00d4b0a7a00d33066fb5. The replacement decode is in the existing nonzero-exit path after stderr is fully collected, so invalid bytes no longer mask the exit code while valid UTF-8 remains intact. The captured CP950 regression exercises both public run methods and checks the caller-visible error; the ASCII/UTF-8 controls preserve exact diagnostics. No blocking findings.

Verified all 22 hosted checks passed on this commit, including Windows tests. This was a source review; I did not run local tests or independently reproduce the native Windows npm-shim failure.

@seratch seratch changed the title fix(codex): preserve subprocess errors for non-UTF8 stderr fix(extensions): preserve subprocess errors for non-UTF8 stderr Sep 27, 2026
@seratch seratch added this to the 0.22.x milestone Sep 27, 2026
@seratch
seratch merged commit 549fcee into main Sep 27, 2026
22 checks passed
@seratch
seratch deleted the codex/fix-codex-stderr-5185 branch September 27, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex CLI stderr decoded as strict UTF-8 raises UnicodeDecodeError instead of RuntimeError on non-UTF-8 Windows

3 participants