GeezerVison is showing github.com — Skip pull requests from forks by default by mhegazy · Pull Request #2114 · anthropics/claude-code-action
Conversation
mhegazy
commented
Nov 21, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Human: @mhegazy
Requested by Mohamed · project thread
Breaking change: allow_fork_prs now defaults to "false". The action skips pull requests from forks, and workflow_run events for a fork's run, unless the workflow opts in. Workflows on @v1 get this with the next release. Those on @main get it on merge.
Migration
To keep working on forks, read Pull requests from forks, then add:
- uses: anthropics/claude-code-action@v1
with:
allow_fork_prs: "true"
Workflows that already set the input are unaffected, except as noted for "false" below.
What changes without the opt-in
- Mentions and prompts on fork pull requests stop running Claude. This includes a team member's own fork, deleted forks, closed pull requests and setups with
allowed_non_write_users.
- A skip is green and quiet. The step succeeds with a warning in the run. It posts no comment and sets no Claude outputs. A required check that only runs the action passes without a review, and later steps that parse
structured_output need to handle an empty value.
- Some failing runs turn green. A fork's
pull_request and review events, which failed for lack of credentials, are now skipped.
- Comments need a permission on every pull request. A triggering comment now makes the action look up where the branch is, including for branches in your own repository. A custom token without
pull-requests: read fails with "Could not find out whether pull request #N is from a fork".
- Issues,
workflow_dispatch, schedule and claude-code-base-action are unchanged.
Change for workflows that set "false"
A fork's run that has credentials now goes through the write and bot checks before the skip. A run they refuse fails, as it does today with the default, so later steps in the job don't go ahead. This covers pull_request_target, workflow_run, comments on the conversation, and in a private repository other fork events that get a token or the Anthropic secrets. A bot that allowed_bots doesn't list fails too.
The flaky-test example now skips fork runs at the job, and the docs' review recipes say that they need the opt-in for forks. The structured output snippets handle an empty output.
Testing
bun test (1493 pass), typecheck, prettier and the workflow hardening check, with @octokit/rest 20.1.2 in place of the locked 21.1.1, which this environment couldn't install.
- Ran
src/entrypoints/run.ts against a mock GitHub for 25 event cases, on main, with the new default and with "true". The cases covered writers and outsiders, deleted forks, bots, private repositories and same-repository pull requests. With "true", results matched main. The mock ends once a run starts preparing.
- Not run on GitHub Actions or with a real model.
Generated by Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
allow_fork_prs now defaults to false. Workflows that need forks set it to
"true".
On pull_request_target and workflow_run, the write checks run before the
skip, so a run they refuse still fails.
Co-authored-by: mhegazy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟡 src/github/validation/fork-pr.ts — Comment-triggered runs on same-repository pull requests now fail when a custom github_token lacks pull-requests: read; on the base default they ran. With allow_fork_prs defaulting to "false" (action.yml:50), isCommentOnRefusedForkPr no longer returns early and calls pulls.get for every triggering PR comment (fork-pr.ts:59). A 403 or 404 is rethrown at fork-pr.ts:73, which fails the step. Fix: a comment on a PR that is not from a fork must not fail for lack of PR read, for example by limiting the lookup to runs that check out the PR head, or by ending in a warned skip instead of an error. (Finding ID: f-e2e10b48)
Why this was flagged
Trigger: an issue_comment on a pull request whose branch is in the same repository, in a workflow that passes prompt (agent mode) and a github_token without pull-requests: read, for example a job with only issues: write in a private repository. On the base, forksAllowed() fell back to "true", so the guard at fork-pr.ts:47-54 returned false with no API call. Now the guard passes, pulls.get at fork-pr.ts:59 gets 403/404, toLookupError marks it not retryable, and fork-pr.ts:73-75 throws "Could not find out whether pull request #N is from a fork". run.ts:490 fails the step and no tracking comment exists yet, so the commenter gets a red run and no reply. Nothing else on this path needed PR read on the base: the author check uses payload.issue.user (untrusted-pr.ts:90-91) and the collaborator endpoint (untrusted-pr.ts:142), and only warns on failure (untrusted-pr.ts:160).
Verification: action.yml:50 default is now "false", and src/github/validation/fork-pr.ts:17-18 forksAllowed() no longer falls back to "true". octokit.pulls.get at fork-pr.ts:59 runs for every PR conversation comment, same-repo or not. A plain 403/404 is non-retryable, so the catch at fork-pr.ts:71-75 throws, which fails the step. On base the guard returned false with no API call because the default was "true".
-
🟡 docs/usage.md — Workflows built from the documented structured-output pattern now fail with an expression error whenever the action skips a fork's run. The skip is a green step that sets no structured_output (run.ts:291-296). The snippet's next step evaluates fromJSON(steps.analyze.outputs.structured_output) at docs/usage.md:258 and again at :277-278, and fromJSON of an empty string is an error. Fix: every documented consumer of structured_output must tolerate an empty value, for example by guarding with steps.analyze.outputs.structured_output != '' first, as docs/security.md:86 now asks. (Finding ID: f-0d708f31)
Why this was flagged
Trigger: a workflow that follows docs/usage.md:245-260 and runs on workflow_run or pull_request_target for a fork owned by someone with write access, or on pull_request from any fork. With allow_fork_prs defaulting to "false" (action.yml:50) the action returns at src/entrypoints/run.ts:218 or run.ts:291-296 after a warning; structured_output is only set at run.ts:478-479, after a session. The step succeeds, so the following step's if at docs/usage.md:258 runs fromJSON(''), which GitHub Actions rejects, and the job fails with a JSON parse error unrelated to the real cause. On the base default, a writer's fork run went through a session and produced the output, so this job passed. The diff edits docs/usage.md and adds the warning at docs/security.md:86 that later steps must handle empty outputs, and it gated examples/test-failure-analysis.yml:21-23, but left this snippet and the one at docs/usage.md:276-278 unguarded.
Verification: src/entrypoints/run.ts:218-221 and :291-297 both do core.warning(FORK_REFUSED); return;, so the step succeeds with no outputs. The only place structured_output is set is src/entrypoints/run.ts:479, after a Claude session. docs/usage.md:258 still shows if: fromJSON(steps.analyze.outputs.structured_output).is_flaky == true with no guard, and :277-278 repeat the pattern.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+215
to
221
|
|
const hasRepositoryCredentials =
|
|
|
isWorkflowRunEvent(context) ||
|
|
|
process.env.GITHUB_EVENT_NAME === "pull_request_target";
|
|
|
if (isRefusedFork && !hasRepositoryCredentials) {
|
|
|
core.warning(FORK_REFUSED);
|
|
|
return;
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 (optional) Workflows that set allow_fork_prs: "false" on pull_request_target or workflow_run now get a failed step for every outside contributor's fork PR, where they got a green skip. hasRepositoryCredentials at run.ts:215-217 exempts those events from the early skip at run.ts:218. The run then reaches the write check, which throws at run.ts:256 before the relocated skip at run.ts:291. Fix: a refused fork should end the same way whoever the actor is; keep the skip green and expose the refusal as an output that later steps can gate on, or fail for writers' forks too.
Why this was flagged
Trigger: a pull_request_target or workflow_run event for a fork whose author lacks write access, in a workflow that already sets allow_fork_prs: "false". On the base, isRefusedForkEvent(context) returned at the top of run() with only a warning, before any token. Now run.ts:218 skips only when !hasRepositoryCredentials, so the run mints a token at run.ts:229 and checkWritePermissions at run.ts:249 refuses the actor, throwing "Actor does not have write permissions to the repository" at run.ts:256-258. The population is every external contributor PR in repositories that chose "false" precisely to stay quiet on forks: each now shows a red check, and where that check is required the PR is blocked. The action offers no setting that restores the green skip; only a job-level if does. The dismissal rested on the PR text and docs/security.md:88 calling it deliberate, but the outcome is inconsistent: a writer's fork still skips green at run.ts:291-296.
Verification: Head src/entrypoints/run.ts:214-221 skips early only when isRefusedFork && !hasRepositoryCredentials. Those events now reach setupGitHubToken() at line 229 and checkWritePermissions at line 249. For an outsider that returns false, and lines 255-258 throw "Actor does not have write permissions to the repository". The relocated skip at lines 291-297 is never reached.
Finding ID: f-0aa8960e
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks. I read these against the code:
- f-ac0f73da, f-1416ba7f: correct. Both are cases where the skip should come after the checks, so that a run they refuse still fails. I'll carry both in the next push.
- f-1f1c9784, f-0d708f31: correct. The recipe's note and the structured output snippets will be fixed in the same push.
- f-0aa8960e: intended, and listed under "Change for workflows that set
"false"". A run the write checks refuse fails, so that later steps don't go ahead.
- f-e2e10b48: correct as described. It is listed under migration. Skipping on a failed lookup would hide real failures, so it stays an error for now.
- f-fcac0fd4: correct as described. It is listed as "green and quiet". Posting a comment is a separate decision for the maintainer.
Generated by Claude Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
A bot that allowed_bots doesn't list now fails instead of being skipped. So
does a refused actor's fork event in a private repository that gets
credentials. Also corrects two doc examples.
Co-authored-by: mhegazy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
2 other optional suggestions (nits or notes on pre-existing code) were found and not posted.
Still open from earlier reviews (2):
- Unresolved: 2 minor or pre-existing.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 27, 2026
Reviewers
ant-kurt
Awaiting requested review from ant-kurt
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|