Skip to content

ci: never check out fork PR head in claude-code-review pull_request_target job#70

Merged
jnasbyupgrade merged 2 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-claude-review-checkout
Jul 26, 2026
Merged

ci: never check out fork PR head in claude-code-review pull_request_target job#70
jnasbyupgrade merged 2 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-claude-review-checkout

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

actions/checkout refuses fork-PR checkouts under pull_request_target unless allow-unsafe-pr-checkout: true is set explicitly. This broke the claude-review job's checkout step deterministically whenever its internal cost gate reached decision=run (see the failing run linked from #60: https://github.com/Postgres-Extensions/pgxntool/actions/runs/30218144501/job/89835769849).

Check out the base branch only (drop repository:/ref:) instead of the fork's head, rather than opting into the unsafe flag. Per anthropics/claude-code-action's own security guidance (docs/security.md), this is the preferred pattern for pull_request_target: the action reads PR content via its own GitHub token/API (already has pull-requests read/write for posting the review) rather than needing the fork's files checked out locally.

This keeps pull_request_target (needed for fork PRs to access CLAUDE_CODE_OAUTH_TOKEN — plain pull_request withholds secrets from fork-triggered runs, per the existing comment in this file). Because pull_request_target always runs the workflow file from the base branch, this specific check can't turn green on its own PR — it will only start passing on PRs opened after this merges.

Related pgxntool-test PR: Postgres-Extensions/pgxntool-test#34

actions/checkout now refuses to check out fork PR code under
pull_request_target unless allow-unsafe-pr-checkout is explicitly set,
which broke the claude-review job for PRs from the trusted
jnasbyupgrade fork. Opt in explicitly; safe here because the job is
already gated to that fork owner only. Also bump actions/checkout to
v6 while touching this step.

Mirrors the same fix already applied on Postgres-Extensions/cat_tools.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b9696f0e-1f7d-4490-ace1-e202103faf96

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Supersede the allow-unsafe-pr-checkout opt-in from the previous commit.
Per anthropics/claude-code-action's own security guidance
(docs/security.md), the preferred pattern for pull_request_target is to
check out the base ref only and let the action read PR content via the
GitHub API — it already has a token with pull-requests read/write. This
avoids ever writing fork code to disk, rather than opting into the
"unsafe" checkout flag.

Matches the fix applied in the paired pgxntool-test PR
(Postgres-Extensions/pgxntool-test#34).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jnasbyupgrade jnasbyupgrade changed the title ci: allow fork-PR checkout for gated claude-code-review workflow ci: never check out fork PR head in claude-code-review pull_request_target job Jul 26, 2026
@jnasbyupgrade
jnasbyupgrade marked this pull request as ready for review July 26, 2026 21:21
jnasbyupgrade added a commit to Postgres-Extensions/pgxntool-test that referenced this pull request Jul 26, 2026
Related pgxntool PR:
Postgres-Extensions/pgxntool#70

Short version: always pull CI from `master`, for security reasons. See
#34 for details.
@jnasbyupgrade
jnasbyupgrade merged commit c38cf2a into Postgres-Extensions:master Jul 26, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant