fix(codex): make plugin install failures triageable and skip unsupported CLIs - #1024
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(codex): make plugin install failures triageable and skip unsupported CLIs#1024posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
…ted CLIs `CodexMCPClient.installPlugin()` built its captured exception from `result.stderr` alone. `spawnSync` reports failure three different ways — a spawn-level `error`, a non-zero `status`, or a terminating `signal` — and Codex sometimes writes the reason to stdout, so all of those surfaced as a bare `Codex plugin install failed: ` with nothing after it. - Fold `error`, `status`, `signal`, stderr and stdout into the captured message, with a placeholder so the tail is never empty. - Skip the capture for failures that are not wizard bugs: an out-of-date Codex CLI, a user interrupt (Ctrl-C during the marketplace clone), and transient network/TLS errors while Codex clones the repo. - Probe `codex --help` for a `plugin` subcommand in `supportsPlugin()` so users on an older CLI are not offered a plugin install that cannot work. Probing `codex plugin --help` does not work — clap short-circuits on `--help` and an older CLI prints top-level help with exit 0. - Resolve the Codex state directory from `CODEX_HOME` (falling back to `~/.codex`) in both `isPluginInstalled()` and the stale-cache retry, which previously hardcoded `~/.codex` and so cleared the wrong directory. cwd: /tmp/workspace/repos/posthog/wizard Generated-By: PostHog Code Task-Id: b5afd218-55b9-42a7-aac4-bb22b666082d
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CodexMCPClient.installPlugin()captured its exception fromresult.stderralone.spawnSyncreports failure three different ways — a spawn-levelerror, a non-zerostatus, or a terminatingsignal— and Codex sometimes writes the reason to stdout instead. Every one of those arrived in error tracking as a bareCodex plugin install failed:with nothing after it, so the dominant failure mode was untriageable.Two real bugs were hiding behind that noise:
supportsPlugin()only checkedcommand -v codex, so users on a Codex CLI predatingplugin marketplacewere offered a plugin install that cannot work — it fails withunexpected argument 'marketplace' foundand was reported as a crash. They finish the wizard but silently never get the PostHog plugin.~/.codex, but Codex resolves its state directory fromCODEX_HOME. For anyone with a custom Codex home it deleted the wrong directory and re-failed.isPluginInstalled()had the same blind spot.Changes
All in
codex.ts:error,status,signal, stderr and stdout into the captured message, with a placeholder so the tail is never empty.codex --helpfor apluginsubcommand insupportsPlugin(), cached per client. Note that probingcodex plugin --helpdoes not work: clap short-circuits on--help, so an older CLI prints top-level help and exits 0. The command list is the reliable signal.CODEX_HOME ?? ~/.codexin bothisPluginInstalled()and the stale-cache retry.Test plan
Unit tests: 30 pass in
codex.test.ts(11 new, covering each blank-message path, the non-actionable skips, the--helpprobe, andCODEX_HOME).typecheckshows the same 36 pre-existing errors as a clean tree, none incodex.ts;eslintclean. Full suite matches baseline exactly (87 failed files / 29 failed tests before and after — pre-existing, build artifacts absent in the sandbox).Verified against real Codex binaries rather than only mocks, driving the actual module:
spawnSync: spawn ENOENT, EACCES, SIGINT, and error-on-stdout each produced exactlyCodex plugin install failed:before the change.@openai/codex@0.81.0(old) and@openai/codex@0.146.0(current). Old CLI:codex --helplists noplugincommand andplugin marketplace addexits 2 withunexpected argument 'marketplace'→supportsPlugin()now returnsfalseandinstallPlugin()captures nothing. Current CLI:pluginis listed →supportsPlugin()returnstrue.CODEX_HOME, and that a realplugin marketplace addwrites[marketplaces.posthog]to$CODEX_HOME/config.tomland the cache to$CODEX_HOME/.tmp/marketplaces/posthog— the two paths this PR now resolves correctly.LLM context
Authored by Claude Code from a PostHog error-tracking inbox report. One correction to the report's framing worth recording: it stated 415 of 545 occurrences carry an empty message. Querying the class directly, truly blank is 161/545 (137 users). The next-largest bucket, 178 occurrences, is the Codex npm wrapper crashing when its vendored binary is missing — those do carry stderr text. The
--helpprobe incidentally silences those too, since a broken wrapper fails--helpas well.Created with PostHog Desktop from this inbox report.