Repository navigation
feat: clear pending review requests and reviewer-assignees - #2675
anchit-goel wants to merge 13 commits into
Conversation
…rsion Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Workflow concurrency, live draft-state validation, and independent error handling need correction.
Review effort: Lite
Findings: 3
Open (3)
What changed in this PR
Adds cleanup of pending review requests and reviewer assignees when a pull request is converted to draft.
Changes:
- Adds draft-state cleanup logic.
- Triggers cleanup on
converted_to_draft. - Adds Jest coverage for cleanup and error handling.
| File | Summary |
|---|---|
.github/workflows/on-review.yml |
Adds the draft cleanup workflow job. |
.github/scripts/bot-pr-add-reviewers-as-assignees.js |
Implements review-state cleanup. |
.github/scripts/__tests__/jest/bot-pr-add-reviewers-as-assignees.test.js |
Tests cleanup behavior and error paths. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughWhen a pull request is converted to draft, a workflow invokes a new function. The function fetches live pull request data, withdraws pending individual and team review requests, and removes eligible individual reviewers from assignees. ChangesDraft review cleanup
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant GitHubActions
participant clearReviewStateOnDraft
participant GitHubPullsAPI
GitHubActions->>clearReviewStateOnDraft: Invoke for converted_to_draft
clearReviewStateOnDraft->>GitHubPullsAPI: Fetch current pull request data
GitHubPullsAPI-->>clearReviewStateOnDraft: Return requested reviewers, teams, and assignees
clearReviewStateOnDraft->>GitHubPullsAPI: Remove pending reviewer and team requests
clearReviewStateOnDraft->>GitHubPullsAPI: Remove qualifying reviewers from assignees
Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: hiero-ledger/hiero-sdk-python/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Advanced
Run ID: e55f2011-385f-4aa6-8c0b-e0d440e9bea1
📒 Files selected for processing (3)
.github/scripts/__tests__/jest/bot-pr-add-reviewers-as-assignees.test.js.github/scripts/bot-pr-add-reviewers-as-assignees.js.github/workflows/on-review.yml
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
…urrency group Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
75eae95 to
e2abb47
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: hiero-ledger/hiero-sdk-python/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 5215d01e-af8b-4857-98cc-28c88c9fa549
📒 Files selected for processing (3)
.github/scripts/__tests__/jest/bot-pr-add-reviewers-as-assignees.test.js.github/scripts/bot-pr-add-reviewers-as-assignees.js.github/workflows/on-review.yml
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
|
@danielmarv kindly review. |
danielmarv
left a comment
There was a problem hiding this comment.
Thanks @anchit-goel sorry for the late review
One change needed before approval, plus a few smaller items.
1. Checkout ref (blocking)
The new job checks out github.event.pull_request.base.sha || github.sha. Everywhere else in the repo, including the add job in this file, pull_request_target jobs pin to the default branch. base.sha is the base commit the PR was last synced against, not the current tip of main. So after merge, any PR last synced before this lands will load a script without the new export and fail with TypeError: clearReviewStateOnDraft is not a function. The || github.sha fallback is also never reached.
ref: ${{ github.event.repository.default_branch }}
2. Error handling across the two API calls (suggestion)
Right now only a 403 from removeRequestedReviewers lets the assignee cleanup continue. Any other error, such as a 422 because a request was withdrawn between the get and the remove, throws and skips the assignee step. That leaves the PR half cleaned up. Could you record the first error, still run the assignee cleanup, and rethrow at the end? Splitting the individual and team withdrawals into separate calls would also stop a problem with one from blocking the other. It would be worth confirming on a fork that GITHUB_TOKEN can withdraw team requests at all.
…p error handling Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
|
Thanks @danielmarv! Both items have been addressed:
|
MonaaEid
left a comment
There was a problem hiding this comment.
Hi @anchit-goel , I suggest testing this on your fork and sharing the links to those tests. If you need any help with the testing, feel free to reach out to me... thank you
|
Hi @anchit-goel, This pull request has had no activity for 10 days. Are you still working on it?
If you're no longer working on this, please comment Reach out on discord or join our office hours if you need assistance. From the Python SDK Team |
|
Hey @anchit-goel, do you need any help testing this? |
…back Signed-off-by: anchit-goel <anchitgoel5@gmail.com>
|
Hi @MonaaEid, I've tested the end-to-end draft conversion flow on my fork. Here is the link to the successful test run: https://github.com/anchit-goel/hiero-sdk-python/actions/runs/39121000217 Additionally, I updated the workflow's runs-on config so it seamlessly falls back to ubuntu-latest when running on personal forks (while continuing to use hl-sdk-py-lin-md on hiero-ledger). |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: hiero-ledger/hiero-sdk-python
- Branch: main
- File: .coderabbit.yaml
- Commit: 562017f
- Layers: Repository YAML
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
e4e99d2c-cf43-478e-9907-0c54d41ac9f9
📒 Files selected for processing: 1
.github/workflows/on-review.yml
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
| github.event.action == 'converted_to_draft' | ||
|
|
||
| concurrency: | ||
| group: reviewer-assignee-${{ github.event.pull_request.number }} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Prevent later jobs from canceling pending draft cleanup.
This group is shared with add-reviewers-as-assignees. If that job is running when draft cleanup becomes pending, a later job for the same PR can replace the pending cleanup. GitHub’s default concurrency queue retains only one pending job, even with cancel-in-progress: false. A workflow_dispatch add-reviewers job can therefore leave the draft PR’s pending review requests intact. Configure the shared group to retain queued jobs, or use another approach that cannot drop draft cleanup. (docs.github.com)

Description:
Withdraw pending review requests and remove reviewer-added assignees when a pull request is converted to draft.
clearReviewStateOnDraftin.github/scripts/bot-pr-add-reviewers-as-assignees.jsto withdraw pending individual/team review requests and clean up reviewer assignees (excluding the PR author).clear-review-state-on-draftjob in.github/workflows/on-review.ymlonpull_request_target.types: [converted_to_draft]..github/scripts/__tests__/jest/bot-pr-add-reviewers-as-assignees.test.jscovering draft-clearing logic and error-handling paths.Related issue(s):
Fixes #2542
Notes for reviewer:
github.rest.pulls.removeRequestedReviewers.reviewer-assignee-draft-${{ github.event.pull_request.number }}).Checklist