fix(server): restore merge actions on hosts without the stacks API #12645
main fromrefs/pull/12645/head·opened View on GitHubWhat Changed#
Recognize HTTP 404 in gh stderr as not-found in VcsProcess, so hosts without the stacks API can reach the existing no-stack fallback.
Limit that fallback to the stacks listing and verify access before returning no stack. A listing 404 triggers a read-only request for one commit on the same PR, using the same host and credentials. The commit-list endpoint requires the same pull-request read permission as the stacks API. If the probe fails, its error propagates; a 404 while reading an already discovered stack's details also stays an error.
Replace the pre-classified fallback mock with raw process-output tests through VcsProcess, GitHubCli, and GitHubPullRequestCli. Cover both observed 404 formats, denied/missing PR access, invalid credentials, rate limits, and service failures.
Why#
On GitHub Enterprise Server, the stacks endpoint returns gh: Not Found (HTTP 404). The process boundary currently classifies this as command-failed, so the existing not-found fallback never runs. An otherwise mergeable PR stays stuck on Retry stack lookup, with the normal merge action hidden.
GitHub also uses 404 for inaccessible resources. Verifying PR-read access prevents an authorization-scoped 404 from being silently treated as an unstacked PR. A repository-metadata or PR-detail probe would be weaker: those can succeed without pull-request read permission. The client-side stack guard and merge-permission checks are unchanged.
Validation#
- Regression tests fail before their corresponding fixes: raw 404 classification, failed access probes, and known-stack detail failures.
- All 312 tests pass across
VcsProcess.test.ts,GitHubCli.test.ts,GitHubPullRequestCli.test.ts,PullRequestSyncReactor.test.ts, andpullRequestDetail.logic.test.ts. - Server TypeScript check, targeted lint, formatting, and
git diff --checkpass. - Read-only GHES check: the stacks listing returns 404 while the PR commit-list probe succeeds.
- Initial fix was tested in an isolated local UI: reproduced Retry stack lookup, then verified Squash and merge and its confirmation dialog. A rebuilt macOS app successfully squash-merged a real enterprise PR and displayed Merged.
No UI components or layouts change. Screenshots from the local validation contain private enterprise repository details, so they are not attached.
Checklist#
- This PR is small and focused.
- I explained what changed and why.
- Regression tests cover the actual CLI failure rather than only a pre-classified mock.
- Existing UI behavior was verified locally, including a completed merge.
Summary by CodeRabbit#
- Bug Fixes
- Pull requests are marked as not stacked only after a 404 stack-preview response is successfully verified.
- Existing stack information is preserved when retrieving additional pull request details fails.
- GitHub CLI errors now provide more accurate handling for missing pull requests, authentication failures, rate limits, permission issues, service outages, and network errors.
Fixes #14458
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
- @@ -93,3 +93,4 @@9393 (normalized.includes("could not resolve to a pullrequest") ||9494 normalized.includes("repository.pullrequest") ||9595 normalized.includes("no pull requests found for branch") ||96+ normalized.includes("http 404") ||
🟠 High
vcs/VcsProcess.ts:96An inaccessible GitHub resource is classified as
not-found, so an expired or insufficiently scoped token causesGitHubClito raiseGitHubPullRequestNotFoundErrorandgetPullRequestStackto returnnull, discarding the existing stack and entering the non-stack merge flow. The generichttp 404match also covers GitHub's authorization-scoped 404 responses; remove it or restrict it to an explicit pull-request-not-found message so authentication failures remain actionable.- normalized.includes("http 404") ||🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/vcs/VcsProcess.ts around line 96: An inaccessible GitHub resource is classified as `not-found`, so an expired or insufficiently scoped token causes `GitHubCli` to raise `GitHubPullRequestNotFoundError` and `getPullRequestStack` to return `null`, discarding the existing stack and entering the non-stack merge flow. The generic `http 404` match also covers GitHub's authorization-scoped 404 responses; remove it or restrict it to an explicit pull-request-not-found message so authentication failures remain actionable.Fixed in bedb2a19b. The fallback now applies only to the stacks listing and verifies PR-read access before returning
null. It probesGET /repos/{owner}/{repo}/pulls/{number}/commits?per_page=1with the same host and credentials; every probe failure propagates. Unlike the basic repository/PR endpoints, listing PR commits requires the same pull-request read permission as listing stacks.A not-found error fetching an already discovered stack's details is no longer caught by the fallback either. This keeps access failures actionable and preserves the previous stack instead of clearing it.
Added regression coverage for access-probe 404/401/403, signed-out credentials, 429/503, and known-stack detail failures. All 312 focused tests pass, along with server typecheck and targeted lint. The read-only GHES check still returns a stacks 404 with a successful permission probe, preserving the original fix.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Approvability#
Verdict: Would Approve
Macroscope's review found this PR approvable — This is a focused two-file bug fix that restores the existing no-stacks fallback through one
gherror-classification change, with regression tests covering the raw CLI path. The generic HTTP 404 match carries an unresolved risk of treating authentication-scoped 404 responses as missing pull requests, which remains a significant correctness concern.Not approved because:
- 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
5b7875e8-0ce3-4153-ad67-bcd9671f01bc📥 Commits
Reviewing files that changed from the base of the PR and between 3bfbe59c2de1d96070f3761ff7342d53649b6d58 and bedb2a19bad6f05fc39edf9189f946a12b8fea37.
📒 Files selected for processing (2)
apps/server/src/pullRequest/GitHubPullRequestCli.test.tsapps/server/src/pullRequest/GitHubPullRequestCli.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough#
GitHub CLI HTTP 404 failures now use the
not-foundclassification. A stacks preview 404 now triggers a pull request access check. The stack read returnsnullonly when that check succeeds, and related failures propagate.Changes#
GitHub CLI stack handling
Layer / File(s) Summary Classify HTTP 404 failures
apps/server/src/vcs/VcsProcess.tsGitHub command failures containing http 404now use thenot-foundclassification.Verify stack access after 404
apps/server/src/pullRequest/GitHubPullRequestCli.ts,apps/server/src/pullRequest/GitHubPullRequestCli.test.tsA stacks preview 404 triggers a commits endpoint check. A successful check returns null; verification and detail failures propagate. Tests cover the typed error mappings and mocked process calls.Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)#
sequenceDiagram participant GitHubPullRequestCli participant VcsProcess participant GitHubAPI GitHubPullRequestCli->>VcsProcess: Read stacks preview VcsProcess->>GitHubAPI: Request stacks data GitHubAPI-->>VcsProcess: Return 404 GitHubPullRequestCli->>VcsProcess: Check pull request commits VcsProcess->>GitHubAPI: Request commits with --silent GitHubAPI-->>VcsProcess: Return success or typed failure VcsProcess-->>GitHubPullRequestCli: Return null or propagate failureSuggested reviewers:
bil0000🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3… Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. Title check ✅ Passed The title clearly identifies the primary fix: restoring merge actions on hosts without the stacks API. Description check ✅ Passed The description includes the required What Changed, Why, and Checklist sections. It also provides validation details and explains that no UI changes apply, so screenshots are not required. ✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
Comment `@coderabbitai help` to get the list of available commands.github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XS
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
juliusmarminge added labelsmacroscope-review
Note
Written by
claude-opus-5-5on behalf of MariaHi! We are cleaning up open PRs, and this one does not say which model or harness was used to create it. If this change is really important, we recommend rebuilding the PR with a newer model and noting the model and harness in the PR description.
maria-rcks closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed