Repository navigation
fix(codex-proxy): report failed codex runs as errors, not successful stops - #677
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 2
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0a1b07747
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'codex-proxy-test-')); | ||
| const home = path.join(tmp, 'home'); | ||
| fs.mkdirSync(path.join(home, '.local', 'bin'), { recursive: true }); | ||
| fs.writeFileSync(path.join(home, '.local', 'bin', 'codex'), STUB, { mode: 0o755 }); |
There was a problem hiding this comment.
Force the proxy test to select its stub
On the NixOS hosts configured by this repository, latestCli.codex is installed system-wide (nixos/environment/default.nix:407), while findCodexBinary() checks /run/current-system/sw/bin/codex before $HOME/.local/bin/codex (bin/codex-proxy.mjs:93-101). Therefore, changing HOME and writing this stub does not isolate the test: it invokes the real authenticated Codex binary, potentially making paid/network calls and causing these assertions to fail or hang. Add an injectable binary override or otherwise ensure the proxy selects the stub.
Useful? React with 👍 / 👎.
Fixes #676
The close handler in
bin/codex-proxy.mjsignored the child's exit code and signal and did not track stderr, so a failedcodex execrun was reported as a successfulstop— HTTP 200 with empty content when nothing was produced, and HTTP 200 carrying truncated text when partial output preceded the failure. Stream mode likewise ended with astopchunk +[DONE].Fix (mirrors the muse-proxy #670/#672 pattern):
stderrTail(last 2000 chars) and any spawn error.code !== 0is a failure regardless of content produced: non-stream returns 500 withCodex execution failed: <last stderr line | spawn error | signal | exit code>; stream mode writes adata:-framed error event +data: [DONE]and no chunk claimsfinish_reason: stop.Tests: new
bin/codex-proxy.test.mjswith a stubcodexat$HOME/.local/bin/codex— success (both modes), FAILME (no output, exit 3), FAILPARTIAL (partial item.completed, exit 3), SIGKILLME (empty-stderr signal fallback). Local: 19/19 across codex-proxy + muse-proxy + proxy-port suites. Ablation: with the proxy fix reverted, exactly the 3 new failure tests fail (1 pass / 3 fail); restored, all pass.Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit