Repository navigation
fix(watch-pr): report a gh that cannot start as a status-query blocker - #820
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
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.
When the watcher cannot start
ghat all, for example because it is not on PATH or the spawn fails with a system error, the spawn error escapesrun()as a raw rejection. Nothing above it converts that into aWatcherQueryError, so the CLI dies with an uncaught stack trace and never prints a JSON verdict. Callers that expect the documented status-query BLOCKER (exit 7, "verify current PR context, GitHub authentication, and API availability") get a crash instead. Under Bun the error is thrown synchronously fromspawn; under Node it arrives as anerrorevent, and neither path was handled.run()now treats a command that cannot start the same as one that exits nonzero: it resolves with code -1 and the spawn error as stderr. The existingrunJsonpath then raises acommand-exitquery failure, so the error goes through the normal retry budget and ends as a status-query BLOCKER whose detail names the problem (for exampleExecutable not found in $PATH: "gh"). Callers that already checkcode !== 0, such as the origin and checks fast paths, fall back as they do for any other failed command.Validation: added a github.test.ts case that runs
GhGitHubReader.pullRequestin a subprocess with a PATH that has nogh. On main it receives the raw "Executable not found" error; with the fix it receives acommand-exitWatcherQueryError. Running the CLI by hand with--status-onlyand noghon PATH now prints the BLOCKER JSON and exits 7 instead of a stack trace. Ranbun test watch-pr check-plan.test.ts(62 pass),bun run typecheck,node scripts/validate-plugins.mjs,node scripts/generate-pstack-harness-trees.mjs --check,node --test pstack/skills/*/scripts/test/*.test.mjs(57 pass), andgit diff --check.Note
Low Risk
Narrow change to subprocess error handling in the GitHub CLI wrapper; improves fail-closed behavior without altering successful
ghpaths.Overview
When
ghcannot be started (missing from PATH, spawn failure), the watch-pr GitHub helper no longer lets that error bubble out as an uncaught rejection.run()now treats “command failed to start” like a nonzero exit: it resolves withcode: -1and the error text instderr, covering Bun’s synchronousspawnthrow and Node’serrorevent.runJsonthen raises the existingcommand-exitWatcherQueryError, so the CLI can surface the usual status-query BLOCKER (exit 7) instead of crashing.A subprocess test runs
GhGitHubReader.pullRequestwith a PATH that has noghand expectscommand-exitrather than a raw executable-not-found string.Reviewed by Cursor Bugbot for commit d37cde9. Bugbot is set up for automated code reviews on this repo. Configure here.