ci: iterate JSON array root when extracting Claude review text#146
Conversation
The action writes \`execution_file\` as a single JSON array (\`JSON.stringify(messages, null, 2)\` in run-claude-sdk.ts), not as JSONL. The previous \`jq -r 'select(.type == "result") | .result\`\` filter evaluated \`.type\` against the array root, hit \`Cannot index array with string "type"\`, and exited 5. With \`bash -e\` that propagated and failed the Extract step before the explicit empty- output guard could fire, so all four \`claude-review-*\` jobs failed in ~35s with no captured comment (PR #144 run 25279155808). Add \`.[]\` to iterate over the array root in both the result-message and assistant-text-fallback filters. Verified locally with a sample matching run-claude-sdk.ts's structure: old filter -> exit 5 + parse error; new filter -> review text + exit 0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ 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: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ 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. Review rate limit: 0/1 reviews remaining, refill in 39 minutes and 11 seconds.Comment |
|
🚅 Deployed to the summit-pr-146 environment in Summit 3 services not affected by this PR
|
There was a problem hiding this comment.
Pull request overview
This PR fixes the Claude review extraction logic in the PR CI workflow so Claude review jobs can read execution_file correctly after the earlier migration to posting reviews from the action output. It keeps the existing review flow intact while updating the jq filters to match the actual JSON shape produced by the Claude action.
Changes:
- Update all four Claude review jobs to iterate over a JSON array root when extracting the final
resultmessage. - Apply the same array-root fix to the assistant-text fallback extractor in each Claude review job.
- Preserve the existing failure behavior when no extractable review output is found.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ssing output Three additional bugs in the previous PR 146 commit (fc83c6c) that local end-to-end testing surfaced: 1. \`tail -1\` chops the multi-line .result string. Claude's review is a single string with embedded newlines; jq -r emits them as physical line breaks. \`tail -1\` would have kept only the final summary line ("Summary: 0 CRITICAL, 1 HIGH, ..."). The blocking-check greps for \`[(CRITICAL|HIGH)]\` (with brackets) which lives in the body, not the bracketed-summary form — so a real HIGH/CRITICAL finding would have been silently dropped from /tmp/review.txt and the job would have passed. Catastrophic. Fix: \`[.[] | select(.type == "result")] | last | .result // empty\` — collect, take last array element, no tail. 2. jq exits 5 on parse errors of malformed JSON. Under the GitHub Actions default shell (bash --noprofile --norc -eo pipefail {0}), pipefail propagates that through the substitution and set -e kills the step before our explicit empty-output guard fires. Add \`|| true\` to mask jq exit codes; the explicit \`[ -z "$REVIEW" ]\` guard then handles it. 3. SDKResultMessage has two variants: SDKResultSuccess (with .result: string) and SDKResultError (no .result, has .errors[]). When Claude errors mid-task, .result is missing — the assistant-text fallback now joins all text blocks across messages with double-newlines so the comment is informative rather than empty. Also: Extract step now writes a heading-prefixed fallback to /tmp/review.txt on failure paths so Post can post it directly without duplicating the heading (which both Claude's prompt instructions and the previous Post step were prepending). Single canonical heading. Verified end-to-end against the actual Claude Code stream-JSON shape (JSON.stringify(SDKMessage[]) per base-action/src/run-claude-sdk.ts): - multi-line .result: full body preserved ✓ - HIGH-finding multi-line .result: blocking-check still fires ✓ - SDKResultError (no .result): assistant-text fallback ✓ - empty array / malformed JSON / missing file: exit 1 with clear error, fallback comment posted, job fails ✓ Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Follow-up to #145. PR #144's CI run (25279155808) showed all four
claude-review-*jobs failing in ~35s with no captured comment. Root cause: the action writesexecution_fileas a single JSON array (JSON.stringify(messages, null, 2)inrun-claude-sdk.ts), not as the JSONL stream the previous filter assumed.The old filter
jq -r 'select(.type == "result") | .result'evaluated.typeagainst the array root and hitCannot index array with string "type", exiting 5. Withbash -ethat propagated and failed theExtract review outputstep before the explicit empty-output guard could fire — exactly the silent-pass failure mode #145's Finding A fix was designed to prevent (the empty/tmp/review.txtfrom the: > /tmp/review.txtline + the downstream[ ! -s ]blocking-check correctly turned an unparseable result into a job failure).Fix: prepend
.[]to both filters (result message + assistant-text fallback) so they iterate over the array root.Verified locally against a sample matching the action's actual file shape:
Test plan
pr-cipasses*-generaljobs run (still gated by thegeneral_reviewshell step from ci: post Claude reviews from execution_file; fix general_review filter #145)🤖 Generated with Claude Code