Skip to content

fix(ci): restore fork filter for pull_request_review_comment events#1426

Open
worktrunk-bot wants to merge 1 commit intomainfrom
fix/issue-1424
Open

fix(ci): restore fork filter for pull_request_review_comment events#1426
worktrunk-bot wants to merge 1 commit intomainfrom
fix/issue-1424

Conversation

@worktrunk-bot
Copy link
Collaborator

Problem

PR #1421 removed the fork filter (head.repo.full_name == github.repository) from the pull_request_review_comment trigger, based on the assumption that this event type has secret access for fork PRs like pull_request_target and issue_comment do.

This assumption was wrong — run 22914840420 failed at checkout with Input required and not supplied: token, confirming that pull_request_review_comment does not have secret access for fork PRs.

Solution

  • Restore the fork filter (github.event.pull_request.head.repo.full_name == github.repository) in the if: condition
  • Restore the workflow comment explaining the fork filter
  • Restore the "Does not trigger" entry for fork PR inline review comments
  • Add a new "Fork PR secret availability" reference table to .github/CLAUDE.md documenting which event types have secrets for fork PRs, to prevent this mistake from recurring

Testing

Workflow-only change — no code tests to run. The fix reverts the logic to the pre-#1421 state which was working correctly.


Closes #1424 — automated triage

PR #1421 removed the fork filter based on the incorrect assumption that
pull_request_review_comment has secret access for fork PRs. It does not —
run 22914840420 failed at checkout with an empty token. Restore the fork
filter and document fork PR secret availability for all event types.

Closes #1424

Co-authored-by: Claude <noreply@anthropic.com>
@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label Mar 10, 2026
max-sixty pushed a commit that referenced this pull request Mar 10, 2026
## Summary

- Add `github.event.issue.user.login != 'worktrunk-bot'` to the `issues`
trigger in `claude-mention.yaml`
- Document the new filter in `.github/CLAUDE.md` "Does not trigger" list

## Problem

The hourly review workflow creates issues (like #1424) that incidentally
mention `@worktrunk-bot` in body text — e.g., "comment contained
`@worktrunk-bot`". This triggers `claude-mention` on the `issues` event,
which then duplicates the hourly review's work, including creating a
second fix PR (#1425 vs #1426 for the same issue).

## Fix

Add an author check to skip issues created by `worktrunk-bot` itself,
consistent with the existing `comment.user.login != 'worktrunk-bot'`
loop-prevention checks on `issue_comment` and
`pull_request_review_comment` events.

Closes #1428

## Test plan

- [ ] Verify the `if:` condition syntax is valid (CI should pass)
- [ ] Confirm the next hourly review run doesn't trigger a
claude-mention run on its issues


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@max-sixty
Copy link
Owner

I don't understand — we don't have access to the secrets from pull_request_review_comment but we do with pull_request_target and issue_comment?

can you really research this? we just want something that runs on any interaction, including comments on fork PRs...

@worktrunk-bot
Copy link
Collaborator Author

Good question — I dug into this properly.

Why the difference: It's a GitHub platform distinction based on which repo context the event runs in:

Event Runs in context of Secrets on fork PRs
pull_request_target Base repo Yes
issue_comment Base repo Yes
pull_request_review_comment Fork repo No
pull_request_review Fork repo No
pull_request Fork repo No

pull_request_target and issue_comment were specifically designed to run in the base repo's context (so maintainers can react to fork PRs with secrets). There's no equivalent pull_request_review_comment_target event — GitHub just never created one.

Run 22914840420 confirmed this: the pull_request_review_comment trigger on a fork PR failed at checkout with Input required and not supplied: token — the WORKTRUNK_BOT_TOKEN secret was empty.

Options for making inline review comments work on fork PRs:

  1. workflow_run two-stage pipeline (GitHub's recommended workaround): A secretless pull_request_review_comment workflow saves the event payload as an artifact, then a workflow_run-triggered workflow downloads it and runs claude-code-action with secrets. This is the only approach that actually works, but adds significant complexity — two workflows, artifact passing, and claude-code-action would need to handle reconstructed event context rather than native GitHub event payloads.

  2. Accept the gap (current PR): Fork PR users use conversation tab comments (issue_comment, which has secrets) instead of inline review comments. This is what the PR currently implements — restore the fork filter and document the limitation.

Given that fork PRs are relatively rare and conversation tab comments work fine for them, option 2 seems like the right trade-off — but happy to build the workflow_run pipeline if you'd prefer full coverage.

@max-sixty
Copy link
Owner

this seems like a strong claim and so needs stronger evidence — find primary sources + issues discussing this

@max-sixty
Copy link
Owner

didn't the bot respond here, for example: #1408 (comment)

(though later there stops responding!)

@worktrunk-bot
Copy link
Collaborator Author

Good catch — and this is exactly the kind of thing I should have traced before claiming it. I dug into the actual workflow runs for PR #1408 to answer both questions.

The bot's response at discussion_r2906398164 was NOT triggered by pull_request_review_comment. It was triggered by an issue_comment event — specifically your conversation comment at 15:54:48 UTC mentioning @worktrunk-bot. That fired issue_comment run 22862093653 (success, completed 16:03:20), and the bot posted its reply as a review comment via the API at 16:03:04.

Every pull_request_review_comment run on PR #1408 was skipped by the fork filter — all 6 of them. The bot's initial review was triggered by pull_request_target (run 22852797352, success).

"Later there stops responding" — exactly right. The later comments (2910069729, 2911871360) were pure review comments on the Files tab. These only trigger pull_request_review_comment (skipped for forks) — no issue_comment event was fired, so the bot was never invoked.

Primary sources on fork PR secret access

The GitHub docs on events state that for fork PRs, secrets are not passed to the runner (except a read-only GITHUB_TOKEN). The key distinction:

  • pull_request_target and issue_comment run in the base repo's context → secrets available
  • pull_request, pull_request_review, pull_request_review_comment run in the fork's context → no secrets

There is no pull_request_review_comment_target variant. This is a known gap — community discussion #55940 documents the same issue for pull_request_review, noting "it's the same issue as pull_request vs pull_request_target but there is no pull_request_review_target."

So the current state is actually working correctly for fork PRs — conversation tab comments (issue_comment) trigger the bot with secrets, while Files tab review comments (pull_request_review_comment) get filtered. The gap is only for inline review comments that don't have a corresponding conversation comment.

Given this, the PR as-is is the right fix — restore the fork filter and document the limitation. Want me to update the PR description to clarify this mechanism?

@max-sixty
Copy link
Owner

but this seems to suggest that the events are sent, no? https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull-request-events-for-forked-repositories-2

Pull request events for forked repositories

For pull requests from a forked repository to the base repository, GitHub sends the pull_request, issue_comment, pull_request_review_comment, pull_request_review, and pull_request_target events to the base repository. No pull request events occur on the forked repository.

@worktrunk-bot
Copy link
Collaborator Author

You're right that the events are sent to the base repo — that quote is about event delivery (where the webhook goes), not about secret access. All five events fire on the base repo, but only some of them get secrets.

The primary source is the docs page you linked. Each event type has its own section, and the ones subject to fork restrictions have a "Workflows in forked repositories" subsection. Specifically:

  • pull_request_review_comment has the subsection, which states: "With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository."
  • issue_comment does not have this subsection — no fork restriction on secrets.
  • pull_request_target explicitly says it "runs in the context of the default branch of the base repository" — secrets available by design.

The empirical evidence matches: run 22914840420 logs show Secret source: None for a pull_request_review_comment event on a fork PR, and checkout failed because WORKTRUNK_BOT_TOKEN was empty. Meanwhile issue_comment runs on the same fork PR (#1408) succeeded with secrets — e.g., run 22862093653.

So the table is: issue_comment and pull_request_target get secrets for fork PRs; pull_request, pull_request_review, and pull_request_review_comment do not.

@max-sixty
Copy link
Owner

OK, that does look reasonable.

Do lots of people complain about this? It seems like one very annoying hole in the approach, such that only in this tiny corner (inline comments on a forked PR) can a bot not be triggered by secrets? Search for places where people have raised this issue and what others do about it.

@worktrunk-bot
Copy link
Collaborator Author

Yes, it's a well-known pain point. There are several community discussions about the missing *_target variants:

  • Discussion #55940 — directly about pull_request_review lacking a _target variant. A commenter says: "Too bad there isn't a pull_request_review_target event. Maybe one day more *_target events will be available." No GitHub response.
  • Discussion #26651 — asks to elevate GITHUB_TOKEN permissions for pull_request_review on forks. No resolution.
  • Discussion #50161 — general complaints about fork PR secret restrictions, 50+ comments.

What other bots do: Most accept the gap. AI review bots (CodeRabbit, Presubmit, claude-code-action) use pull_request_target for the initial automated review and issue_comment for follow-up interactions. None of them solve the inline review comment gap on fork PRs specifically — they just don't respond to those. claude-code-action#339 documents the same failure mode we hit.

The workflow_run two-stage pipeline (documented pattern, template) is the "proper" workaround, but I couldn't find any bot project actually using it for inline review comments — the complexity isn't worth it given that conversation tab comments (issue_comment) work fine as a fallback.

So the approach in this PR (filter fork PRs, document the limitation) matches what everyone else does. The gap only affects inline review comments on fork PRs specifically — a small enough corner that projects live with it.

max-sixty added a commit that referenced this pull request Mar 10, 2026
## Summary

- Rewrite the hourly reviewer's Step 7 ("Report findings") to prefer
creating PRs over issues
- PRs are now the default for any fixable problem (skill edits, workflow
tweaks, CLAUDE.md updates)
- Issues are only for problems too large or ambiguous to fix directly
- PR descriptions carry the full analysis (run ID, log excerpts, root
cause) — replacing what would have been the issue body
- Instructs the bot to keep findings cohesive (grouped PRs, not many
small patches)

This eliminates the duplication problem from #1425/#1426, where the
hourly reviewer created an issue and the triage bot raced to also fix
it. With the reviewer going straight to PR, there's no issue for triage
to pick up.

Requested by @max-sixty in
#1425 (comment).

## Test plan

- [ ] Workflow YAML passes validation (CI lint check)
- [ ] Next hourly run creates PRs instead of issues for small fixes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Maximilian Roos <5635139+max-sixty@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude-mention: pull_request_review_comment events lack secrets for fork PRs (regression from #1421)

2 participants