Skip to content

fix(pr-monitor): CodeRabbit 発イベントで backstop が actor 拒否される不具合を修正 (allowed_bots)#260

Open
aloekun wants to merge 2 commits into
masterfrom
fix-pr-monitor-allowed-bots
Open

fix(pr-monitor): CodeRabbit 発イベントで backstop が actor 拒否される不具合を修正 (allowed_bots)#260
aloekun wants to merge 2 commits into
masterfrom
fix-pr-monitor-allowed-bots

Conversation

@aloekun

@aloekun aloekun commented Jul 11, 2026

Copy link
Copy Markdown
Owner

概要

WP-09(PR #258 でマージ済み)の GitHub Actions バックストップの本命トリガーが常に失敗していた不具合を修正する。

不具合

claude-code-action は既定でトリガー元 actor の権限を検査し、bot actor を拒否する。バックストップの本命トリガー(CodeRabbit のレビュー完了 = pull_request_review、walkthrough = issue_comment)は actor が coderabbitai[bot] のため、以下のエラーで常に失敗していた:

Action failed with error: Workflow initiated by non-human actor: coderabbitai (type: Bot). Add bot to allowed_bots list or use '*' to allow all bots.

PR #259pull_request_review run(run 29149352791)で実観測。PR #258 のスモークテストが通ったのは pull_request: opened の actor が人間(リポジトリ owner)で権限チェックを通過したためで、本命トリガー(bot 発)の障害を見逃していた。

修正

action step に allowed_bots: "coderabbitai[bot]" を追加し、この bot のみを許可("*" は使わず、任意 bot トリガーは禁止)。

セキュリティ上の注意(workflow にコメントで明記)

公式 docs/security.md: 「Allowed bots are not checked for repository permissions」 — allowlist した bot は GitHub の権限チェックを完全にバイパスする。したがって本 job の安全性は、pre-push security review が PR #258 で確立した読み取り専用の多層防御permissions: contents: read / allowedTools scope / エージェント無 write / persist-credentials: false)が唯一の担保になる(ADR-022 原則6 の 2 不変条件)。GitHub の権限ゲートに頼れないぶん、この多層防御の重要性が増す。

副次効果: github-actions[bot](本 workflow 自身の投稿者)は allowlist 外のため bot トリガーが弾かれ、自己トリガーが二重に防止される。

検証(マージ後に有効化)

GitHub の仕様上、pull_request_review / issue_comment トリガーはデフォルトブランチ(master)上の workflow 定義で発火する。したがって本修正は master にマージされて初めて有効化される:

  • 本 PR 自身の CodeRabbit レビュー(pull_request_review)は master の旧定義(allowed_bots 無し)で動くため、依然として actor 拒否で失敗する(想定内。regression ではない)。
  • マージ後、次の PR の CodeRabbit レビューが修正済み master 定義で発火し、backstop run が成功して分析コメントが付くことを確認する(従来は失敗していた本命経路)。

YAML 構文 + allowed_bots の反映は確認済み。

変更

  • .github/workflows/pr-monitor.yml — action step に allowed_bots 追加 + 設計 / セキュリティコメント

WP-09 の受け入れ基準「セッション閉鎖中の CodeRabbit レビュー完了に無人で分析コメント」は、この修正で初めて成立する。

Summary by CodeRabbit

  • 改善
    • 自動レビューの実行条件を調整し、指定された自動ボットからの起動を確実に処理できるようになりました。
    • 自動処理が重複して実行されるケースを防止しました。

…wed_bots)

WP-09 の GitHub Actions バックストップの本命トリガー (CodeRabbit のレビュー完了 =
pull_request_review / walkthrough = issue_comment、actor が coderabbitai[bot]) が、
claude-code-action の非人間 actor 拒否 ("Workflow initiated by non-human actor:
coderabbitai") で常に失敗していた (PR #259 の pull_request_review run で実観測)。
#258 のスモークテストが通ったのは actor が人間 (pull_request opened) だったため、
本命トリガーの障害を見逃していた。

- action step に allowed_bots: "coderabbitai[bot]" を追加し当該 bot のみ許可 ("*" 不使用)。
- allowlist した bot は GitHub 権限チェックをバイパスする (公式 docs/security.md) ため、
  本 job の安全性は読み取り専用多層防御が唯一の担保になる点をコメントで明記 (ADR-022 原則6)。
- 副次効果: github-actions[bot] は allowlist 外のため自己トリガーが二重に防止される。
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8c0998e0-fc6c-4825-8093-77b2b25990d2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

PR監視ワークフローの Claude Code Action に allowed_bots を追加し、coderabbitai[bot] を許可対象として設定します。

Changes

PR監視ワークフロー

Layer / File(s) Summary
許可 bot の設定
.github/workflows/pr-monitor.yml
Claude Code Action に allowed_bots: "coderabbitai[bot]" を追加し、bot actor の権限チェック対象を設定する。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • aloekun/claude-code-hook-test#258: 同じ PR監視ワークフローにおける coderabbitai[bot] のトリガーおよび自己起動抑止方針を定義しています。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed CodeRabbit起因のイベントでbackstopがactorに拒否される問題と、allowed_bots追加という実際の変更内容に一致しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-pr-monitor-allowed-bots

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…w_dispatch)

pr-monitor の run が PR の Status Check として現れ、concurrency cancel や bot-actor 失敗が CI 失敗 (赤× / UNSTABLE) に見える問題を解消する (PR #260 の analyze run cancelled で実観測)。原因: check_run はイベントごとに異なる対象 SHA へ発行され、pull_request 起点の run のみ PR head SHA に紐づき PR チェック化する。CodeRabbit が数分でレビューを返すため opened run が review イベントで concurrency cancel され、cancelled が赤× として残る (ほぼ毎 PR で必然)。監視 ≠ CI として役割ベースでトリガーを分離: pull_request(opened/ready) 削除、pull_request_review/issue_comment 維持、workflow_dispatch(input pr_number) 追加、allowed_bots 維持、PR番号解決を 3 箇所で inputs.pr_number 対応。ADR-022 原則6 のトリガー記述を更新。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant