-
Notifications
You must be signed in to change notification settings - Fork 71
feat: improve CodeRabbit review guardrails and verification #5122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rnetser
merged 7 commits into
RedHatQE:main
from
rnetser:feat/coderabbit-review-improvements
Jun 8, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
213c228
feat: improve CodeRabbit review guardrails and verification
rnetser 66f9cd1
fix: improve test plan checklist and unresolve logic
rnetser f9a02bb
fix: address CodeRabbit review comments
rnetser 19520df
fix: use plain list instead of checkboxes in test plan
rnetser 85c8e63
fix: add pagination and fix thread opener detection
rnetser 257e99c
fix: correct bot login, improve heuristic, clarify wording
rnetser 1ba9d1b
fix: require PR author reply and conditional unresolve warning
rnetser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # description: Unresolve CodeRabbit review threads that were resolved by the PR author | ||
| # without addressing them. Runs on every push to a PR. | ||
| # | ||
| # Logic: If a CodeRabbit review thread was resolved by someone other than | ||
| # coderabbitai[bot], and the resolver's last reply does NOT contain a substantive | ||
| # response (e.g., "fixed", "addressed", code snippet, or explanation), the thread | ||
| # is unresolved so CodeRabbit can re-evaluate it. | ||
|
|
||
| name: Unresolve unaddressed CodeRabbit threads | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [synchronize] | ||
|
|
||
| concurrency: | ||
| group: unresolve-threads-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| # Required to unresolve review threads and add comments | ||
| pull-requests: write | ||
| contents: read | ||
|
|
||
| jobs: | ||
| unresolve-threads: | ||
| if: "!endsWith(github.event.pull_request.user.login, '[bot]')" | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| steps: | ||
| - name: Unresolve prematurely resolved CodeRabbit threads | ||
| env: | ||
| GH_TOKEN: ${{ secrets.BOT3_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| REPO: ${{ github.repository }} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| PR_AUTHOR: ${{ github.event.pull_request.user.login }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # Fetch resolved review threads with pagination | ||
| ALL_THREADS="[]" | ||
| CURSOR="" | ||
| while true; do | ||
| if [ -n "$CURSOR" ]; then | ||
| AFTER_ARG="-f after=$CURSOR" | ||
| else | ||
| AFTER_ARG="" | ||
| fi | ||
| PAGE=$(gh api graphql -f query=' | ||
| query($owner: String!, $repo: String!, $pr: Int!, $after: String) { | ||
| repository(owner: $owner, name: $repo) { | ||
| pullRequest(number: $pr) { | ||
| reviewThreads(first: 100, after: $after) { | ||
| nodes { | ||
| id | ||
| isResolved | ||
| opening_comment: comments(first: 1) { | ||
| nodes { | ||
| author { | ||
| login | ||
| } | ||
| } | ||
| } | ||
| recent_comments: comments(last: 5) { | ||
| nodes { | ||
| author { | ||
| login | ||
| } | ||
| body | ||
| } | ||
| } | ||
| } | ||
| pageInfo { | ||
| hasNextPage | ||
| endCursor | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ' -f owner="${REPO%%/*}" -f repo="${REPO##*/}" -F pr="$PR_NUMBER" $AFTER_ARG) | ||
|
|
||
| # Append nodes to accumulated list | ||
| NODES=$(echo "$PAGE" | jq '.data.repository.pullRequest.reviewThreads.nodes') | ||
| ALL_THREADS=$(echo "$ALL_THREADS $NODES" | jq -s 'add') | ||
|
|
||
| # Check for next page | ||
| HAS_NEXT=$(echo "$PAGE" | jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.hasNextPage') | ||
| if [ "$HAS_NEXT" != "true" ]; then | ||
| break | ||
| fi | ||
| CURSOR=$(echo "$PAGE" | jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.endCursor') | ||
| done | ||
|
|
||
| # Process each resolved thread | ||
| echo "$ALL_THREADS" | jq -r --arg pr_author "$PR_AUTHOR" ' | ||
| .[] | ||
| | select(.isResolved == true) | ||
| | select(.opening_comment.nodes[0].author.login == "coderabbitai") | ||
| | select( | ||
| # No substantive PR-author reply exists in the recent window | ||
| (any(.recent_comments.nodes[]; | ||
| .author.login == $pr_author | ||
| and ((.body // "") | length) >= 15 | ||
| ) | not) | ||
| ) | ||
| | .id | ||
| ' | while read -r thread_id; do | ||
| if [ -n "$thread_id" ]; then | ||
| echo "Unresolving thread: $thread_id" | ||
| if gh api graphql -f query=" | ||
| mutation { | ||
| unresolveReviewThread(input: {threadId: \"$thread_id\"}) { | ||
| thread { | ||
| id | ||
| isResolved | ||
| } | ||
| } | ||
| } | ||
| "; then | ||
| # Add a comment to the thread explaining why it was unresolved | ||
| gh api graphql -f query=" | ||
| mutation { | ||
| addPullRequestReviewThreadReply(input: {pullRequestReviewThreadId: \"$thread_id\", body: \"\u26a0\ufe0f This thread was automatically unresolved because it was resolved without a substantive response. Please address the review comment and explain how it was resolved before resolving this thread again.\"}) { | ||
| comment { | ||
| id | ||
| } | ||
| } | ||
| } | ||
| " || echo " Warning: failed to add comment to $thread_id" | ||
| else | ||
| echo " Warning: failed to unresolve $thread_id" | ||
| fi | ||
| fi | ||
| done | ||
|
|
||
| echo "Done checking CodeRabbit threads." | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test Execution Plan
.coderabbit.yaml,.github/workflows/request-coderabbit-test-instructions.yml, and.github/workflows/unresolve-coderabbit-threads.yml. Noutilities/,libs/, ortests/Python code was touched.