fix(ci): claude-review を OAuth 優先にし失効 API キーによる無言失敗を解消する - #1064
Conversation
Claude CLI は ANTHROPIC_API_KEY を CLAUDE_CODE_OAUTH_TOKEN より優先する。 claude-code-review.yml は両方を無条件に claude-code-action へ渡していたため、 失効した API キーが有効な OAuth トークンを握り潰し、初回 API 呼び出しの 401 を 約 180 秒リトライしたのちエラー本文なしで is_error:true / num_turns:1 / total_cost_usd:0 で終了していた。 旧 action SHA は is_error:true をジョブ失敗として扱わなかったため、 2026-07-29 以降レビューが一度も実行されないまま success に見えていた。 OAuth トークンがある間は API キーを渡さないようにし、契約テストと ADR 0013 に Claude Actions 全体の資格情報優先順位を明記する。 Closes #1063 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
📝 WalkthroughWalkthroughThe Claude Code Review workflow now prioritizes ChangesClaude authentication precedence
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
test/claude-workflow-contract.test.jsOops! Something went wrong! :( ESLint: 10.8.0 ReferenceError: describe is not defined 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/claude-workflow-contract.test.js (1)
126-133: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert that the OAuth input remains configured.
This test checks the conditional
anthropic_api_keyexpression, but it does not checkclaude_code_oauth_token. A future edit could remove the OAuth input while this test still passes. Add an assertion for both credential inputs.Proposed test addition
const workflow = readWorkflow('.github/workflows/claude-code-review.yml'); + expect(workflow).toContain( + "claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}", + ); expect(workflow).toContain( "anthropic_api_key: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN == '' && secrets.ANTHROPIC_API_KEY || '' }}", );The PR objective requires contract coverage for OAuth-first handling.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/claude-workflow-contract.test.js` around lines 126 - 133, Add a second assertion to the test that verifies the OAuth token input itself is configured in the workflow (checking for claude_code_oauth_token input definition), in addition to the existing assertions that verify the anthropic_api_key expression. This ensures both credential inputs are validated, preventing future edits from removing the OAuth input while the test still passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/claude-workflow-contract.test.js`:
- Around line 126-133: Add a second assertion to the test that verifies the
OAuth token input itself is configured in the workflow (checking for
claude_code_oauth_token input definition), in addition to the existing
assertions that verify the anthropic_api_key expression. This ensures both
credential inputs are validated, preventing future edits from removing the OAuth
input while the test still passes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a1320e1-8568-4187-b937-83c264bc61eb
📒 Files selected for processing (3)
.github/workflows/claude-code-review.ymldocs/adr/0013-takt-repo-maintenance-orchestration.mdtest/claude-workflow-contract.test.js
|
🎉 This PR is included in version 1.132.6 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes #1063
Why
claude-reviewジョブがエラー本文なしで失敗し続けていた。{ "type": "result", "subtype": "success", "is_error": true, "duration_ms": 182233, "num_turns": 1, "total_cost_usd": 0 }調査の結果、これは #1061 で新たに発生した問題ではなく、2026-07-29 以降ずっと続いていた無言失敗だった。旧 action SHA (
a92e7c70) がis_error:trueをジョブ失敗として扱わなかったため success に見えていただけで、実際にはレビューが一度も実行されていない。be7b93b1be7b93b1be7b93b1a92e7c70a92e7c70a92e7c70原因
同日・同一シークレットで
claude.ymlは成功している。差分は資格情報の渡し方だけだった。anthropic_api_keyの受け渡しANTHROPIC_API_KEYclaude-opus-5[1m]claude-sonnet-5is_error:true/ 1 turn / $0is_error:false/ 22 turns / $0.89Claude CLI は
ANTHROPIC_API_KEYをCLAUDE_CODE_OAUTH_TOKENより優先する(ADR 0013 に既出)。レビューワークフローだけが失効済み API キーを無条件に action へ渡していたため、初回 API 呼び出しが 401 になり、約 180 秒リトライしたのちエラー本文なしで終了していた。PR #1061 が scheduled-maintenance で特定した「無効キーで 3 分走ってから落ちる」現象と同一。What
.github/workflows/claude-code-review.ymlCLAUDE_CODE_OAUTH_TOKENが空のときだけanthropic_api_keyを渡すtest/claude-workflow-contract.test.jsdocs/adr/0013-...mdCheck Claude authenticationガードは変更していないため、OAuth 未設定・API キーのみの下流リポジトリは従来どおり API キーで動作する。How to test
actionlint .github/workflows/claude-code-review.yml: passtoContainが失敗)Risk
ANTHROPIC_API_KEYシークレットは 08-03 12:00〜08-04 03:02 の間に既に削除済みで、現在のリポジトリシークレットはCLAUDE_CODE_OAUTH_TOKEN/CLAUDE_PATのみ。本 PR はワークフロー側で再発を防ぐもの。claude-reviewジョブはcontinue-on-error: trueのままなので、レビュー失敗がマージをブロックすることはない(偽グリーンの主因は旧 action の挙動であり、こちらは意図的な設定として維持)。review_gate_changedガードでレビューがスキップされるため、修正の実効性は次回以降の PR で確認する。🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation
Tests