Skip to content

ci: fix gh api review-state query in ready-for-review workflow #566

Merged
xdustinface merged 1 commit intov0.42-devfrom
ci/ready-for-review-slurp-compat
Mar 19, 2026
Merged

ci: fix gh api review-state query in ready-for-review workflow #566
xdustinface merged 1 commit intov0.42-devfrom
ci/ready-for-review-slurp-compat

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Mar 19, 2026

gh api does not support combining --slurp with --jq. Pipe paginated output to jq -rs instead so pages are concatenated into a single array before the filter runs.

This is issue was preventing the ready-for-review label from being added when CI completes after CodeRabbit approval.

Summary by CodeRabbit

  • Chores
    • Updated CI workflow logic to normalize paginated review data client-side, improving reliability of automated review aggregation and ensuring consistent detection of the latest bot review state.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

The workflow changes how PR reviews are fetched: the gh api call now uses --paginate piped to jq -rs (client-side aggregation) instead of prior server-side --slurp/--jq filtering; the downstream add → map(select) → sort_by → last → .state // "NONE" pipeline remains.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
​.github/workflows/ready-for-review.yml
Replaced server-side gh api --jq/--slurp usage with gh api --paginate piped into jq -rs to aggregate paginated review results before applying existing filtering/sorting to derive the bot review .state.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 I nibble logs where actions play,
From server trims to client array—
Pages pooled in a gentle heap,
One last review the workflow keeps.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly indicates a fix to the gh api review-state query in the ready-for-review workflow, which directly corresponds to the main change of switching from server-side --slurp --jq flags to client-side jq -rs piping.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/ready-for-review-slurp-compat
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/ready-for-review.yml (1)

130-142: ⚠️ Potential issue | 🔴 Critical

Critical: Missing -r flag causes comparison to always fail.

The jq -s command outputs JSON strings with quotes (e.g., "APPROVED"), but gh api --jq outputs raw strings by default. Without the -r flag, $CODERABBIT_STATE will contain "APPROVED" (with literal quote characters), and the comparison on line 139 against APPROVED (without quotes) will never match.

This means the ready-for-review label will never be added, defeating the purpose of this fix.

🐛 Proposed fix: Add `-r` flag to jq
-            CODERABBIT_STATE=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/reviews" | jq -s '
+            CODERABBIT_STATE=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/reviews" | jq -rs '
               add
               | map(select(.user.login == "coderabbitai[bot]"))
               | sort_by(.submitted_at)
               | last
               | .state // "NONE"
             ')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ready-for-review.yml around lines 130 - 142, The
comparison fails because jq -s produces quoted JSON strings so CODERABBIT_STATE
contains quotes (e.g., "APPROVED"); update the command that sets
CODERABBIT_STATE (the gh api | jq -s ... pipeline) to output raw strings by
adding the jq -r option so the variable holds APPROVED without quotes, ensuring
the subsequent if [ "$CODERABBIT_STATE" != "APPROVED" ] check works as intended.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In @.github/workflows/ready-for-review.yml:
- Around line 130-142: The comparison fails because jq -s produces quoted JSON
strings so CODERABBIT_STATE contains quotes (e.g., "APPROVED"); update the
command that sets CODERABBIT_STATE (the gh api | jq -s ... pipeline) to output
raw strings by adding the jq -r option so the variable holds APPROVED without
quotes, ensuring the subsequent if [ "$CODERABBIT_STATE" != "APPROVED" ] check
works as intended.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4e31c882-7592-4a51-93f6-ddfdb147b353

📥 Commits

Reviewing files that changed from the base of the PR and between 1de2479 and 12db4eb.

📒 Files selected for processing (1)
  • .github/workflows/ready-for-review.yml

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 19, 2026
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.36%. Comparing base (1de2479) to head (0799eb6).
⚠️ Report is 1 commits behind head on v0.42-dev.

Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #566      +/-   ##
=============================================
- Coverage      66.37%   66.36%   -0.02%     
=============================================
  Files            311      311              
  Lines          64979    64979              
=============================================
- Hits           43130    43121       -9     
- Misses         21849    21858       +9     
Flag Coverage Δ
core 75.13% <ø> (ø)
ffi 37.53% <ø> (+0.01%) ⬆️
rpc 28.28% <ø> (ø)
spv 81.12% <ø> (-0.09%) ⬇️
wallet 65.93% <ø> (ø)
see 5 files with indirect coverage changes

`gh api` does not support combining `--slurp` with `--jq`. Pipe paginated
output to `jq -rs` instead so pages are concatenated into a single array
before the filter runs.
@xdustinface xdustinface changed the title ci: pipe gh api --paginate to jq -s instead of using --slurp --jq ci: fix gh api review-state query in ready-for-review workflow Mar 19, 2026
@xdustinface xdustinface merged commit 665bb7b into v0.42-dev Mar 19, 2026
64 of 65 checks passed
@xdustinface xdustinface deleted the ci/ready-for-review-slurp-compat branch March 19, 2026 07:20
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