fix(health-check): pin claude-code version via cache, surface CLI errors#175
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR pins the Claude Code CLI version in the workflow, adds an npm cache for the global install directory and conditional global install, and updates the review script to detect and report Claude CLI failures without silently continuing. ChangesClaude Code CLI Reliability
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Pull request overview
Fixes the daily PR-review health check, which started failing when a new @anthropic-ai/claude-code release (2.1.141) introduced a claude --print regression. Without caching/pinning and with errors silently captured into the report file via stdout redirect, the failure surfaced as a 1-second exit with no diagnostics. The fix mirrors the existing pr-review.yml caching scheme and surfaces CLI errors to the Actions log.
Changes:
- Pin and cache the
claude-codeCLI in the health-check workflow using the sharedCLAUDE_CODE_VERSIONvariable and anactions/cachekey compatible withpr-review.yml. - Add
--no-session-persistenceto theclaude --printinvocation for CI safety. - Wrap the
claudecall inif !so non-zero exits echo the captured stdout/stderr (which Claude writes errors to) to the Actions error log before aborting.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
.github/workflows/daily-pr-review-health.yml |
Adds CLAUDE_CODE_VERSION env, actions/cache@v5 step, and per-user npm prefix install that reuses cached binary. |
scripts/pr_review_health.sh |
Adds --no-session-persistence and surfaces Claude CLI failures by echoing the redirected output to the Actions error log. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request updates the scripts/pr_review_health.sh script to improve error handling during the Claude CLI invocation. It adds the --no-session-persistence flag and wraps the command in a conditional block to capture and report errors if the invocation fails. I have no feedback to provide.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In @.github/workflows/daily-pr-review-health.yml:
- Line 45: Replace the unpinned actions/cache@v5 usage with a pinned commit SHA
for consistency/security: locate the workflow step using "uses:
actions/cache@v5" and change it to the same pattern used elsewhere in the file
(e.g., "uses: actions/cache@<COMMIT_SHA>") by copying the commit SHA style from
the other pinned actions in this workflow so the action is referenced by its
specific commit instead of a floating tag.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6c048692-ced3-4a0e-aaab-23ee320ad78f
📒 Files selected for processing (2)
.github/workflows/daily-pr-review-health.ymlscripts/pr_review_health.sh
| node-version: '20' | ||
|
|
||
| - name: Cache claude-code CLI | ||
| uses: actions/cache@v5 |
There was a problem hiding this comment.
Pin actions/cache to a SHA for consistency and security.
All other actions in this workflow are pinned to commit SHAs (lines 37, 40, 79), but actions/cache@v5 is not. This creates a security and reproducibility gap.
📌 Proposed fix to pin actions/cache
- - name: Cache claude-code CLI
- uses: actions/cache@v5
+ - name: Cache claude-code CLI
+ uses: actions/cache@f689fdddf282194ec20a78de59e81a0a66a5c96e # v5.3.0🤖 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 @.github/workflows/daily-pr-review-health.yml at line 45, Replace the
unpinned actions/cache@v5 usage with a pinned commit SHA for
consistency/security: locate the workflow step using "uses: actions/cache@v5"
and change it to the same pattern used elsewhere in the file (e.g., "uses:
actions/cache@<COMMIT_SHA>") by copying the commit SHA style from the other
pinned actions in this workflow so the action is referenced by its specific
commit instead of a floating tag.
Dev-Lead Fix CI — no-changesPR: #175 | SHA: |
3b64c33 to
72a44c6
Compare
Dev-Lead Fix CI — no-changesPR: #175 | SHA: |
ffde5ae to
e814c5e
Compare
Dev-Lead Fix CI — no-changesPR: #175 | SHA: |
6072701 to
a2e1260
Compare
Dev-Lead Fix CI — failedPR: #175 | SHA: |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/daily-pr-review-health.yml (1)
45-45:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPin
actions/cacheto a commit SHA.Line 45 still uses a floating tag (
actions/cache@v5), which weakens reproducibility and supply-chain integrity versus SHA-pinned actions already used elsewhere in this workflow.Suggested fix
- uses: actions/cache@v5 + uses: actions/cache@f689fdddf282194ec20a78de59e81a0a66a5c96e # v5.3.0🤖 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 @.github/workflows/daily-pr-review-health.yml at line 45, Replace the floating tag "uses: actions/cache@v5" with a commit SHA pin to improve reproducibility and supply-chain integrity; locate the action reference "uses: actions/cache@v5" in the workflow and change it to the corresponding commit SHA (e.g., actions/cache@<full-commit-sha>), matching the pinning style used elsewhere in the workflow and ensuring the chosen SHA is from the official actions/cache repository.
🤖 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.
Duplicate comments:
In @.github/workflows/daily-pr-review-health.yml:
- Line 45: Replace the floating tag "uses: actions/cache@v5" with a commit SHA
pin to improve reproducibility and supply-chain integrity; locate the action
reference "uses: actions/cache@v5" in the workflow and change it to the
corresponding commit SHA (e.g., actions/cache@<full-commit-sha>), matching the
pinning style used elsewhere in the workflow and ensuring the chosen SHA is from
the official actions/cache repository.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8edc87a1-6abb-4819-8474-38475d2be0cc
📒 Files selected for processing (2)
.github/workflows/daily-pr-review-health.ymlscripts/pr_review_health.sh
|
@dev-lead please confirm routing is working — human intent test for shadow period verification. |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
Auto-rebase failed — merge conflict — this branch has conflicts with Claude will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention. To resolve manually instead: |
|
@dev-lead - Review and fix |
Dev-Lead — human (no-changes)Engine ran but made no changes. |
|
@dev-lead - please fix this PR |
CI/CD workflow YAML files commonly use npm install patterns that SonarCloud flags as security hotspots (missing --ignore-scripts, variable package versions). These are expected CI patterns — not application code — and the hotspot rules can't be suppressed via NOSONAR comments for YAML security hotspot categories. Fixes: SonarCloud Code Analysis failure on PR #175. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Review — fix requested (cycle 1/3)The automated review identified the following issues. Please address each one: Findings to fixAutomated review — NEEDS HUMAN REVIEWRisk: MEDIUM SummaryPR adds a new daily health-check workflow and shell script to pin/cache the Claude Code CLI version and surface CLI errors. All CI checks pass (shellcheck, CodeQL, SonarCloud, bats, AgentShield) and the logic is sound, but CodeRabbit left an unresolved CHANGES_REQUESTED for one specific finding: Findings
Reviewed by the PR-review cascade (triage: haiku 4.5 → deep: sonnet 4.6 + duck: gpt-5.4 → audit: opus 4.7). Reply if you need a human review. Additional tasks
The review cascade will automatically re-review after new commits are pushed. |
…oud guidance * fix(dev-lead): relay check_run id, verify CLI, improve SonarCloud guidance Three related improvements surfaced by PR #175's SonarCloud failure: 1. **Relay check_run.id** — the ci-relay dispatch payload was missing the check_run `id`, so `dev-lead-fix-ci.sh` could never fetch annotations for external quality gates (SonarCloud, CodeQL App checks). `ANNOTATIONS` was always `[]` because the API path contained an empty id segment. Now `RELAY_CHECK_ID` is relayed and included as `id` in the checks array. 2. **Verify primary engine CLI after install** — a missing binary caused silent exit 127 failures inside `run_writer`, which incorrectly counted toward the PR exhaustion threshold. A new "Verify primary engine CLI" step fails the workflow early (before any agent work) with a clear error message, so the failure is visible and no exhaustion marker is posted. 3. **Fix-ci SonarCloud guidance** — the prompt listed curl|bash and hardcoded-credentials patterns but omitted the npm-specific hotspots that actually fired on PR #175 (`npm install` without `--ignore-scripts`, variable/`@latest` package versions). Also documented that `# NOSONAR` does not suppress Security Hotspots — only Bugs/Code Smells. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(prompt): address gemini review comments on fix-ci.md - npm install without --ignore-scripts: say "may require manual acknowledgment in SonarCloud UI" (not "document why") — the agent can't perform UI actions and documentation won't clear the hotspot - Change "Fix each identified issue and commit." to "- Fix each identified issue." — bullet formatting matches the rest of the section, and the existing Constraints section already prohibits the agent from committing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: Gemini CLI <gemini-cli@example.com> Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: donpetry-bot <donpetry-bot@users.noreply.github.com>



Root cause
The health check always installs the latest
@anthropic-ai/claude-codewith no caching or version pin. Version 2.1.141 was published at 2026-05-13 22:42 UTC — ~14 hours after the last successful health check run. That version introduced a behaviour change that causesclaude --printto exit 1 in CI.Meanwhile
pr-review.ymlis unaffected: it usesactions/cachewith theCLAUDE_CODE_VERSIONvariable and a cache populated under 2.1.138, so it never saw 2.1.141.How the error was hidden:
claudewrites errors to stdout, not stderr. The invocation used> "$REPORT_FILE", so the error message landed silently in the report file and the step failed with no visible output in the Actions log.Confirming evidence from the failed run (25849827578):
npm installcompleted;claudebinary availableChanges
daily-pr-review-health.ymlCLAUDE_CODE_VERSION: ${{ vars.CLAUDE_CODE_VERSION || 'latest' }}env varactions/cache@v5step with keyclaude-code-<version>-<os>— mirrorspr-review.ymlso both workflows share the same cached binarynpm install -g @anthropic-ai/claude-codewith a cache-aware install that respects the version variablescripts/pr_review_health.sh--no-session-persistenceflag for CI safetyclaudecall inif !so a non-zero exit echoes the CLI output to the Actions error log before aborting — prevents future failures from being silently swallowedTest plan
workflow_dispatchrun of the health check — confirm it uses the cached version and completes successfullyclaude-code-latest-Linuxis shared withpr-review.yml(same binary, same behaviour)clauderelease breaks CI again, the error will now be visible in the Actions log under::error::Claude invocation failed. CLI output follows:🤖 Generated with Claude Code
Summary by CodeRabbit