format-suggest workflow fails on all fork PRs since actions/checkout blocked pull_request_target checkouts

オープン 初心者向け
#2,704 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github-actions
領域
ci-cd, security

調査の方向性

.github/workflows/format-suggest.yaml から始め、その checkout ステップをリンクされている posit-dev/setup-air テンプレートと比較してください。文書化されている checkout オプションまたはより厳格な workflow 分割のどちらを選ぶか決める前に、pull_request_target のセキュリティガイダンスを確認してください。フォークからの pull request が、リポジトリのシークレットを公開したり、信頼できないコードを実行したりすることなく、format-suggest を正常に実行できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Problem

format-suggest.yaml now fails on every pull request coming from a fork. It dies after ~5s in the actions/checkout step with:

Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access.

Example: #2703 (fork PR, format-suggest failed 2026-09-02). For comparison, #2699 (also a fork PR) still passed on 2026-06-19.

Cause

GitHub changed the default behaviour of actions/checkout: checking out a fork's head SHA under pull_request_target (or workflow_run) is refused unless explicitly opted in. Announced 2026-06-18 for v7, backported to the other supported major versions with enforcement on 2026-07-20 — which is why actions/checkout@v4 (a floating major tag) picked it up without any change on our side.

Since pull_request_target runs the workflow definition from the base branch, contributors cannot fix this in their PRs; it has to be changed on main.

Suggested fix

The upstream template this workflow is derived from, posit-dev/setup-air/examples/format-suggest.yaml, has already been updated:

      - uses: actions/checkout@v7
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          allow-unsafe-pr-checkout: true

vs. the current .github/workflows/format-suggest.yaml:

      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}

allow-unsafe-pr-checkout: true is the documented opt-out. It is defensible for this workflow because the checked-out tree is only treated as passive data (air format . does not execute package code), which is the exact use case GitHub calls out as acceptable — but it is worth a conscious decision rather than a copy-paste, so I did not open a PR for it.

The stricter alternative, if you'd rather not opt out at all, is the two-workflow split: run air format . under pull_request (no secrets), upload the diff as an artifact, and post the suggestions from a separate workflow_run job that never checks out fork code.

Other r-lib repos deriving from the same template are presumably affected identically.

References

主要言語
R
スター
2.5k
フォーク
760
平均マージ
1日 6時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

r-lib/devtools のほかの issue

r-lib/devtools の issue をすべて見る

似ている issue

R の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。