LearnNewsExamplesServices
Frontmatter
id9895
titlebug: PullRequestService execAsync calls missing cwd — gh pr diff/checkout fail in headless environments
stateClosed
labels
bugai
assigneestobiu
createdAtApr 11, 2026, 10:09 PM
updatedAtApr 11, 2026, 10:19 PM
githubUrlhttps://github.com/neomjs/neo/issues/9895
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 11, 2026, 10:19 PM

bug: PullRequestService execAsync calls missing cwd — gh pr diff/checkout fail in headless environments

tobiu
tobiu commented on Apr 11, 2026, 10:09 PM

Context

PullRequestService.mjs has two execAsync calls (lines 44, 89) that invoke gh pr checkout and gh pr diff without passing {cwd: aiConfig.projectRoot}. When the MCP server process is spawned from a directory outside the git repo (e.g., CWD = / via stdio transport), both commands fail with exit code 1 because gh cannot resolve the repository context.

Root Cause

SyncService.mjs correctly passes {cwd} to all 5 of its execAsync calls (lines 134-148). PullRequestService.mjs does not — likely an oversight from when the service was first written.

Fix

Add {cwd: aiConfig.projectRoot} to both execAsync calls in PullRequestService.mjs:

  • Line 44: execAsync(\gh pr checkout ${prNumber}`, {cwd: aiConfig.projectRoot})`
  • Line 89: execAsync(\gh pr diff ${prNumber}`, {cwd: aiConfig.projectRoot})`

A2A Context (Fat Ticket)

Discovery Path

Found during PR review of #9894 — the get_pull_request_diff MCP tool returned GH_CLI_ERROR with exit code 1. The same gh pr diff 9894 command succeeded when run from the repo root via shell, confirming CWD as the differentiator.

Scope Boundary

Two-line fix. No architectural changes. No new dependencies.

Verification

After applying the fix, restart the MCP server and call get_pull_request_diff on any merged PR to confirm it returns diff output instead of an error.

tobiu assigned to @tobiu on Apr 11, 2026, 10:09 PM
tobiu added the bug label on Apr 11, 2026, 10:09 PM
tobiu added the ai label on Apr 11, 2026, 10:09 PM
tobiu referenced in commit 4a336f0 - "fix: Add cwd to PullRequestService execAsync calls (#9895)" on Apr 11, 2026, 10:15 PM
tobiu cross-referenced by PR #9896 on Apr 11, 2026, 10:15 PM
tobiu referenced in commit 1113f85 - "fix: Add cwd to PullRequestService execAsync calls (#9895) (#9896) on Apr 11, 2026, 10:19 PM
tobiu closed this issue on Apr 11, 2026, 10:19 PM