Skip to content

fix(pr-review): skip pull_request path for fork PRs (avoid read-only-token 403)#1219

Merged
thepagent merged 1 commit into
mainfrom
fix/pr-review-skip-fork-events
Jun 27, 2026
Merged

fix(pr-review): skip pull_request path for fork PRs (avoid read-only-token 403)#1219
thepagent merged 1 commit into
mainfrom
fix/pr-review-skip-fork-events

Conversation

@chaodu-agent

Copy link
Copy Markdown
Collaborator

Problem

#1218 added pull_request: [opened, synchronize, reopened] to pr-bot-review.yml. But fork PRs run pull_request with a read-only GITHUB_TOKEN, so the job's POST /statuses call returns 403 Resource not accessible by integration and the run fails.

Observed immediately on fork PR #1190 (brettchien, cross-repo): https://github.com/openabdev/openab/actions/runs/28275655386

This is worse than the original 'waiting on cron' state — it's a red failing run on every fork-PR push.

Fix

Guard the job so the pull_request path only runs for same-repo PRs:

if: >-
  github.event_name != 'pull_request' ||
  github.event.pull_request.head.repo.full_name == github.repository
  • schedule / workflow_dispatch → always run (full token; reviews all PRs incl. forks, as before).
  • pull_request from same-repo branch → run (token has statuses: write) → prompt status on rebase/push.
  • pull_request from forkskipped (neutral, not failed); the cron poller still reviews it with full permissions.

Net: keeps the #1218 speedup for same-repo PRs (the common case) while forks behave exactly as they did before #1218 (handled by cron), with no failing runs.

Verification

YAML parses; job if guard confirmed. No other logic changed.

…403)

#1218 added a pull_request trigger, but fork PRs run with a read-only
GITHUB_TOKEN, so creating the 'OpenAB PR Review' status 403s and the run
fails (observed on fork PR #1190). Guard the job to run on pull_request
events only for same-repo PRs; forks continue to be handled by the cron
poller (which runs with full permissions). schedule/workflow_dispatch
always run.

Fixes the failing runs introduced by #1218.
@chaodu-agent chaodu-agent requested a review from thepagent as a code owner June 27, 2026 02:20
@thepagent thepagent merged commit e2dd3fd into main Jun 27, 2026
3 of 4 checks passed
@chaodu-agent

Copy link
Copy Markdown
Collaborator Author

LGTM ✅ — Correctly guards the pull_request event path so fork PRs skip the job (avoiding 403), while same-repo PRs and scheduled runs proceed normally.

What This PR Does

PR #1218 added pull_request triggers to pr-bot-review.yml, but fork PRs run with a read-only GITHUB_TOKEN, causing the commit-status POST to 403 and the workflow to fail. This fix adds a job-level if: guard that skips the event-driven path for fork PRs, relying on the existing cron poller (which has full permissions) to review them.

How It Works

A single job-level if: conditional:

if: >-
  github.event_name != 'pull_request' ||
  github.event.pull_request.head.repo.full_name == github.repository
  • schedule / workflow_dispatch → always runs (event_name ≠ pull_request).
  • Same-repo pull_request → runs (head repo matches).
  • Fork pull_requestskipped (neutral status, not failed).

Findings

# Severity Finding Location
1 🟢 Clean, minimal fix — single condition with clear inline comments .github/workflows/pr-bot-review.yml:23-28
2 🟢 Correct use of >- block scalar for multi-line expression .github/workflows/pr-bot-review.yml:27
3 🟢 PR body clearly documents the problem, fix, and verification
Baseline Check
What's Good (🟢)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants