Skip to content

Fix claude-review checking out untrusted fork PR head#34

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

Fix claude-review checking out untrusted fork PR head#34
jnasbyupgrade merged 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-claude-review-checkout

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Related pgxntool PR: Postgres-Extensions/pgxntool#70

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 pgxntool #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.

Fixes #33

The checkout step used pull_request_target with repository/ref set to
the fork's PR head — GitHub Actions refuses this combination by
default (the pwn-request guard) unless allow-unsafe-pr-checkout is
set, so the review's checkout step failed deterministically whenever
the cost gate reached decision=run.

Per anthropics/claude-code-action's own security guidance
(docs/security.md), the preferred fix for pull_request_target is to
check out the base ref (not the fork's head) and let the action read
PR content via the GitHub API. It already has a GitHub token and
pull-requests read/write for posting the review, so it can fetch the
diff itself without ever writing fork code to disk. This also
preserves pull_request_target (and the secrets/token access it
provides), which pull_request cannot — that path was already tried
and doesn't work for fork PRs.

Fixes Postgres-Extensions#33

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@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: 7c11ba9a-2a10-4626-ac84-29c96dabdb6e

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.

jnasbyupgrade added a commit to jnasbyupgrade/pgxntool that referenced this pull request Jul 26, 2026
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 <[email protected]>
@jnasbyupgrade
jnasbyupgrade merged commit ba85db5 into Postgres-Extensions:master Jul 26, 2026
8 of 9 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.

claude-review workflow fails deterministically on every fork PR (missing allow-unsafe-pr-checkout)

1 participant