review-pr: cannot dismiss approval on fork PRs, leaving stale approval when CI fails
Problem
When the review bot approves a cross-repository (fork) PR and CI subsequently fails, the bot cannot dismiss its own approval — GitHub's dismiss API returns HTTP 404 for cross-repo PRs. This leaves a stale "APPROVED" review contradicting red CI, which could mislead a human maintainer into merging.
Evidence
Run: 22847633269
PR: #1404 (cross-repository PR from ruudk/worktrunk)
Session log: 89f4d777-42f9-4922-88f5-2c68f1c17509.jsonl
Sequence:
- Bot approved commit
c9bdb36at 09:50:45Z - CI failed (
cargo fmtformatting issue) — detected at 09:51:55Z - Bot found review ID
3914195581and called the dismiss endpoint - Got HTTP 404:
{"message":"Not Found","documentation_url":"https://docs.github.com/rest","status":"404"} - Bot correctly identified "likely a permissions issue on fork PRs" and posted a COMMENT review with inline suggestion instead
- Stale APPROVED review remained on
c9bdb36until the author pushed a fix (b741d16) and a new run approved that commit
Secondary issue in same session: The bot also hit a 422 when trying to post an inline suggestion using gh api with -f 'comments[0][path]=...' syntax — gh doesn't parse bracket-indexed parameters as JSON arrays. The bot recovered by switching to a JSON payload file, costing 2 extra tool calls.
Impact
- Stale approval window: Between the CI failure (09:51) and the author's fix commit being approved, the PR showed as "approved" despite failing CI. A maintainer checking at that moment could have merged broken code.
- Wasted tool calls: The dismiss attempt + array syntax retry cost 3 tool calls that could have been avoided.
Suggested fix
Update the review-pr skill to handle cross-repository PRs:
-
Detect fork PRs before approving. Add a pre-approval check:
IS_FORK=$(gh pr view <number> --json isCrossRepository --jq '.isCrossRepository') -
For fork PRs, defer approval until CI passes. Since the bot can't dismiss on forks, the safer workflow is: post COMMENT review -> monitor CI -> approve only after CI passes. This eliminates the stale-approval window entirely.
-
Document the
gh apiarray syntax limitation. The skill's inline suggestion example uses-f 'comments[0][...]'syntax, which doesn't work withgh. The JSON payload approach (which the bot discovered on retry) should be the documented pattern.
Scope
This affects all cross-repository PRs reviewed by the bot. In the current codebase, the review-pr skill has no fork-specific logic — it follows the same approve-then-monitor path regardless of PR origin.
Corrected root cause
The dismiss failure is not a fork PR limitation. It's a wrong HTTP method.
Evidence from run 22845135867 — the same fork PR (#1404), same bot, two dismiss attempts back-to-back:
- POST (default
gh apimethod):gh api "repos/$REPO/pulls/1404/reviews/3913754420/dismissals" -f message="..."→ 404 - PUT:
gh api "repos/$REPO/pulls/1404/reviews/3913754420/dismissals" -X PUT -f message="..."→ Success, state changed toDISMISSED
The GitHub dismiss endpoint requires PUT, not POST. When gh api is called with -f flags but no -X flag, it defaults to POST — which returns 404 on the dismiss endpoint.
In run 22847633269 (the one this issue was filed about), the bot only tried POST and gave up, concluding it was a fork permission issue. But the earlier run on the same fork PR proves PUT works fine.
Fix: Add -X PUT to the dismiss instruction in the review-pr skill (see #1407). PR #1406's deferred-approval approach works as a workaround but adds unnecessary complexity — the simpler fix is using the correct HTTP method.