Repository navigation
checkout_pr_branch: same-repository bot exception does not cover pull_request labeled #71151
Description
Motivation
Label-driven agentic workflows (for example automerge that wakes on a merge-ready label) fail at "Checkout PR branch" when the labeler is a GitHub App. The same App can open or push the PR and pass checkout, but applying a label on that same-repository PR still fails. This blocks production label-triggered approve paths even when the App is listed in GH_AW_ALLOWED_BOTS / on.bots.
Summary
assertTrustedCheckoutRuntime() in actions/setup/js/checkout_pr_branch.cjs skips the collaborator permission lookup for a Bot sender on a same-repository PR, but only for opened, synchronize, ready_for_review, and reopened. For labeled, a GitHub App sender falls through to getCollaboratorPermissionLevel. That endpoint returns none for apps, so checkout fails.
This is the same class of gap as #69311 (which extended the list for ready_for_review / reopened). labeled is still missing on main.
Context
- File:
actions/setup/js/checkout_pr_branch.cjs - Constant:
TRUSTED_BOT_PR_ACTIONS = ["opened", "synchronize", "ready_for_review", "reopened"] - Comment above the exception already states Apps are not collaborators and return
permission: "none". GH_AW_ALLOWED_BOTS/isAllowedBot()is used for comment and review bot trust paths, not forpull_request/pull_request_targetactions. Listing the App inon.botsdoes not help this checkout gate.- Observed with setup action pin
github/gh-aw@cbc32699c3d6f737ad73b03fab1f84b134e94699. TheTRUSTED_BOT_PR_ACTIONSlist is unchanged onmain.
Related prior issues: #64788, #67155, #69311.
Problem
Steps to reproduce
- A same-repository PR authored by a GitHub App (
sender.type: Bot), withhead.repo.id == base.repo.id. - A gh-aw agent workflow that triggers on
pull_requesttypes includinglabeled, includes the generated "Checkout PR branch" step, and lists the App inon.bots/GH_AW_ALLOWED_BOTS. - The App applies a label that starts the workflow (for example a merge-ready label).
- The agent job fails at "Checkout PR branch":
ERR_PERMISSION: Refusing PR checkout: actor 'example-app[bot]' has 'none' permission (requires write or higher)
Expected vs actual
- Expected: Same-repository Bot PR actors that are trusted for
opened/synchronize/ready_for_review/reopenedalso pass checkout when the triggering action islabeled(same head/base repo id checks). - Actual:
labeledfalls through to the collaborator floor →none→ refuse.
Concrete observation
- Triggering actor:
elastic-vault-github-plugin-prod[bot] - Event:
pull_request/labeled(~3s after the App applied the label) GH_AW_ALLOWED_BOTSincluded that bot- Failure: https://github.com/elastic/oblt-aw/actions/runs/39792592249/job/119873400092
Proposal
Add labeled to TRUSTED_BOT_PR_ACTIONS (consider unlabeled if label-removal wakes workflows the same way). Keep the existing same-repository head/base id equality checks. An App that can label a PR already has write on that PR/issue, so this does not meaningfully widen trust beyond the exception already granted for other same-repo bot PR actions.
Optional follow-up (separate if preferred): also honor GH_AW_ALLOWED_BOTS on the pull_request bot path for consistency with comment/review trust.
Please add a unit test for labeled (and unlabeled if included), mirroring the coverage added for #69311.
Scope
| In scope | Out of scope |
|---|---|
Extend same-repo bot PR checkout trust to labeled (and optionally unlabeled) |
Changing collaborator semantics for Apps in general |
| Tests for the new action(s) | Consumer workflow workarounds (for example re-trigger via synchronize) |
Acceptance criteria
- Same-repository Bot sender on
pull_request/pull_request_targetwith actionlabeledpassesassertTrustedCheckoutRuntimewhen head/base repo ids match the runtime repository. - Apps that are not same-repository (fork head) still fail closed.
- Existing trusted actions (
opened,synchronize,ready_for_review,reopened) remain trusted. - Unit tests cover the new action(s).
References
- Prior fix for the same gap on other actions: checkout_pr_branch: same-repository bot exception does not cover pull_request ready_for_review (or reopened) #69311
- App collaborator
nonebackground: checkout_pr_branch: GitHub App bot actors are always refused since #63011 (collaborator permission API returns "none" for apps) #64788 - Repro job: https://github.com/elastic/oblt-aw/actions/runs/39792592249/job/119873400092
Activity
Copilot commentedon Oct 22, 2026
The agent encountered an error and was unable to start working on this issue: The service is temporarily unavailable. Please try again later. (Request id: DBA7:2B6C61:2E2D8E:5ED519:6ADA4BFD)
fr4nc1sc0-r4m0n commentedon Oct 23, 2026
Closing since this seems a transient problem
fr4nc1sc0-r4m0n commentedon Oct 26, 2026
Update — still broken on current pins (reopened)
This was closed after a Copilot start failure looked transient. The gap is still present on
main:TRUSTED_BOT_PR_ACTIONSis still onlyopened,synchronize,ready_for_review, andreopened— nolabeled.New production evidence (2026-10-25)
On an Elastic Obs automerge path that uses
elastic/ai-github-actionsgh-aw-mention-in-pr@main(compiler bump to gh-aw v0.92.5 via elastic/ai-github-actions#2374):elastic-vault-github-plugin-prod[bot].openedsucceeds (bot exception applies) and appliesoblt-aw/ai/merge-ready.approve / agentthen runs onpull_requestlabeledand fails at Checkout PR branch:allowed-bot-users/GH_AW_ALLOWED_BOTSdoes not help: that allow list is used for comment/review bot trust, not forpull_requestaction trust.github/gh-aw@73def160…, which still trusted Bot senders broadly. The failing run usedgithub/gh-aw@cbc32699…with the narrowedTRUSTED_BOT_PR_ACTIONSlist.Ask
Please keep this open until
labeledis covered (either add it toTRUSTED_BOT_PR_ACTIONS, or trust allow-listed same-repo bots for allpull_request/pull_request_targetactions the way comment/review paths already do).Related public consumer pin path: elastic/ai-github-actions#2374.
fr4nc1sc0-r4m0n commentedon Oct 27, 2026
@pelikhan Quick clarification on status after #72074.
The issue asks to add
labeledtoTRUSTED_BOT_PR_ACTIONSso same-repo GitHub App label triggers can checkout when collaborator permission isnone.#72074’s title/body sound like that change, but on current
mainTRUSTED_BOT_PR_ACTIONSis still onlyopened,synchronize,ready_for_review, andreopened. The merged PR also adds a test that same-repo botlabeledevents still require the collaborator permission floor, and the security specs saylabeledmust not use the bot exception.Was #72074 meant to close this by documenting that
labeledstays fail-closed, or is the runtime fix still outstanding? We still hit this in production withelastic-vault-github-plugin-prod[bot]onpull_request/labeled.