Skip to content

ci(security-review): drop pull_request_review trigger (broken on fork PRs)#1310

Merged
tejaskash merged 2 commits into
mainfrom
fix-fork-secrets
May 20, 2026
Merged

ci(security-review): drop pull_request_review trigger (broken on fork PRs)#1310
tejaskash merged 2 commits into
mainfrom
fix-fork-secrets

Conversation

@tejaskash
Copy link
Copy Markdown
Contributor

@tejaskash tejaskash commented May 19, 2026

Why

The pull_request_review trigger was added to give maintainers a way to authorize the security review on community (fork) PRs by approving the review. It works on same-repo PRs but fails silently on fork PRs: GitHub does not inject repo/org secrets into pull_request_review runs when the PR head is a fork, regardless of the reviewer's access level. Today's run on PR #1299 (fork from notgitika) is the proof — the workflow fired, the auth gate passed, then Generate GitHub App token crashed with Input required and not supplied: app-id because vars.APP_ID and secrets.APP_PRIVATE_KEY both resolved to empty.

The pull_request_target event with the labeled action does receive secrets on fork PRs and is the only trigger that actually works end-to-end for community contributions.

What changes

  • Remove pull_request_review from the workflow triggers.
  • Drop the related branches in the auth job (filter clause, isApproval path, review.state == 'approved' check).
  • Update CONTRIBUTING.md to direct maintainers to the safe-to-review label and explain why approving review isn't the trigger.
  • Same-repo maintainer-authored PRs continue to auto-run on opened / reopened / synchronize exactly as before.
  • Community PRs require the safe-to-review label, gated on the labeler's write access.

Test plan

  • Land this. On the next community fork PR, apply safe-to-review and confirm the workflow runs end-to-end (App token resolves, label adds, Bedrock review runs, inline comments + summary post).
  • On a same-repo PR, confirm opened continues to auto-run as before.
  • On a same-repo PR, confirm an approving review no longer triggers the workflow (since the trigger was removed).

…njected on fork PRs

GitHub does not inject repo/org secrets (vars.APP_ID, secrets.APP_PRIVATE_KEY,
the Bedrock OIDC role) into workflows triggered by pull_request_review when the
PR head is a fork, regardless of the reviewer's access level. Approving a fork
PR therefore fired the workflow but the App-token step crashed with 'Input
required and not supplied: app-id' because vars.APP_ID resolved to empty.

The label-on-pull_request_target path does inject secrets and is the only
trigger that works end-to-end for fork PRs. Drop the pull_request_review
trigger entirely; same-repo maintainer PRs auto-run on opened/synchronize as
before, community PRs require the safe-to-review label.
@tejaskash tejaskash requested a review from a team May 19, 2026 19:29
@github-actions github-actions Bot added the size/s PR size: S label May 19, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label May 19, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 19, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.14.0.tgz

How to install

gh release download pr-1310-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.14.0.tgz

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 43.72% 9272 / 21204
🔵 Statements 42.97% 9839 / 22896
🔵 Functions 40.44% 1604 / 3966
🔵 Branches 40.45% 6029 / 14903
Generated in workflow #3134 for commit 9ea4f79 by the Vitest Coverage Report Action

Copy link
Copy Markdown

@agentcore-cli-automation agentcore-cli-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — the rationale is correct: GitHub does not inject repo/org secrets into pull_request_review runs when the PR head is a fork, so the trigger could never have completed the App-token step on community PRs. Removing it (plus the corresponding branches in the auth filter, the auth step if, and the isApproval script path) is the right fix, and the concurrency group cleanup is consistent with that.

The same-repo auto-run path (opened/reopened/synchronize gated on PR author) and the community label path (safe-to-review gated on the labeler) both still resolve correctly through the simplified if and the simplified script. CONTRIBUTING.md is updated to match.

Nothing blocking from me. One trivial nit you can ignore: the comment on lines 96–97 of .github/workflows/pr-security-review.yml still references pull_request_review events as a reason the default GITHUB_TOKEN is read-only — that event no longer triggers the workflow, so the reference is stale. Worth a one-line update next time you're in the file but not worth blocking on.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 19, 2026
Hweinstock
Hweinstock previously approved these changes May 19, 2026
Copy link
Copy Markdown
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing!

notgitika
notgitika previously approved these changes May 19, 2026
Copy link
Copy Markdown
Contributor

@notgitika notgitika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you!

…ry on cancel

Three fixes rolled in:

1. Use the SDK's bundled /security-review slash command instead of inlining
   the prompt. The Claude Code SDK that ships with anthropics/claude-code-action
   exposes /security-review as a registered slash command (visible in the
   'slash_commands' list its system init prints). It drives its own
   git-diff-based context, sub-task fan-out, and false-positive filtering.
   We were re-implementing all of that in a 23 KB inline prompt, plus a
   fragile build step that crashed on fork PRs because
   .github/prompts/security-review.md doesn't exist on the head ref.

   Drops .github/prompts/security-review.md, the Build/Read prompt steps,
   and the python templating. Workflow is ~300 lines lighter.

2. Concurrency: cancel-in-progress: false. Cancelling a run mid-analysis
   leaves the buffer file empty but lets the if: always() summary step
   fire, posting a misleading 'no high-confidence findings' comment.
   Letting both runs complete is the safer default.

3. Summary step branches on steps.review.conclusion. Only post a real
   findings count when the review step actually completed; on
   failure/cancellation/skip, post a transparent status that says the run
   didn't complete and a later run will replace it.
@tejaskash tejaskash dismissed stale reviews from notgitika and Hweinstock via 9ea4f79 May 20, 2026 15:22
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label May 20, 2026
@agentcore-devx-automation
Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label May 20, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/s PR size: S labels May 20, 2026
Copy link
Copy Markdown
Contributor

@notgitika notgitika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tejaskash tejaskash merged commit 43607fa into main May 20, 2026
27 of 28 checks passed
@tejaskash tejaskash deleted the fix-fork-secrets branch May 20, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants