Skip to content

checkout_pr_branch: same-repository bot exception does not cover pull_request labeled #71151

Backlog

Description

@fr4nc1sc0-r4m0n

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 for pull_request / pull_request_target actions. Listing the App in on.bots does not help this checkout gate.
  • Observed with setup action pin github/gh-aw@cbc32699c3d6f737ad73b03fab1f84b134e94699. The TRUSTED_BOT_PR_ACTIONS list is unchanged on main.

Related prior issues: #64788, #67155, #69311.

Problem

Steps to reproduce

  1. A same-repository PR authored by a GitHub App (sender.type: Bot), with head.repo.id == base.repo.id.
  2. A gh-aw agent workflow that triggers on pull_request types including labeled, includes the generated "Checkout PR branch" step, and lists the App in on.bots / GH_AW_ALLOWED_BOTS.
  3. The App applies a label that starts the workflow (for example a merge-ready label).
  4. 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 / reopened also pass checkout when the triggering action is labeled (same head/base repo id checks).
  • Actual: labeled falls through to the collaborator floor → none → refuse.

Concrete observation

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_target with action labeled passes assertTrustedCheckoutRuntime when 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

Activity

  1. locked and limited conversation to collaborators on Oct 22, 2026
  2. unlocked this conversation on Oct 22, 2026
  3. Copilot commented on Oct 22, 2026

    Copilot
    Contributor

    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)

  4. fr4nc1sc0-r4m0n commented on Oct 23, 2026

    @fr4nc1sc0-r4m0n
    Author

    Closing since this seems a transient problem

  5. locked and limited conversation to collaborators on Oct 23, 2026
  6. unlocked this conversation on Oct 23, 2026
  7. fr4nc1sc0-r4m0n commented on Oct 26, 2026

    @fr4nc1sc0-r4m0n
    Author

    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_ACTIONS is still only opened, synchronize, ready_for_review, and reopened — no labeled.

    New production evidence (2026-10-25)

    On an Elastic Obs automerge path that uses elastic/ai-github-actions gh-aw-mention-in-pr @ main (compiler bump to gh-aw v0.92.5 via elastic/ai-github-actions#2374):

    1. Same-repo PR authored by GitHub App elastic-vault-github-plugin-prod[bot].
    2. Dependency-review on opened succeeds (bot exception applies) and applies oblt-aw/ai/merge-ready.
    3. Automerge approve / agent then runs on pull_request labeled and fails at Checkout PR branch:
    ERR_PERMISSION: Refusing PR checkout: actor 'elastic-vault-github-plugin-prod[bot]' has 'none' permission (requires write or higher)
    
    1. Listing the App in allowed-bot-users / GH_AW_ALLOWED_BOTS does not help: that allow list is used for comment/review bot trust, not for pull_request action trust.
    2. Contrast: the previous successful Vault-authored bump (2026-10-18) used older github/gh-aw@73def160…, which still trusted Bot senders broadly. The failing run used github/gh-aw@cbc32699… with the narrowed TRUSTED_BOT_PR_ACTIONS list.

    Ask

    Please keep this open until labeled is covered (either add it to TRUSTED_BOT_PR_ACTIONS, or trust allow-listed same-repo bots for all pull_request / pull_request_target actions the way comment/review paths already do).

    Related public consumer pin path: elastic/ai-github-actions#2374.

  8. locked and limited conversation to collaborators on Oct 26, 2026
  9. unlocked this conversation on Oct 26, 2026
  10. fr4nc1sc0-r4m0n commented on Oct 27, 2026

    @fr4nc1sc0-r4m0n
    Author

    @pelikhan Quick clarification on status after #72074.

    The issue asks to add labeled to TRUSTED_BOT_PR_ACTIONS so same-repo GitHub App label triggers can checkout when collaborator permission is none.

    #72074’s title/body sound like that change, but on current main TRUSTED_BOT_PR_ACTIONS is still only opened, synchronize, ready_for_review, and reopened. The merged PR also adds a test that same-repo bot labeled events still require the collaborator permission floor, and the security specs say labeled must not use the bot exception.

    Was #72074 meant to close this by documenting that labeled stays fail-closed, or is the runtime fix still outstanding? We still hit this in production with elastic-vault-github-plugin-prod[bot] on pull_request / labeled.

  11. locked and limited conversation to collaborators on Oct 27, 2026
  12. unlocked this conversation on Oct 27, 2026
  13. added
    backlog:safe-outputs-git
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai-inspectedbacklog:safe-outputs-gitcommunity

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions