-
-
Notifications
You must be signed in to change notification settings - Fork 18
resolving bug from added feature to not remove unassigned contributor who's made corresponding PR #56
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
base: main
Are you sure you want to change the base?
Conversation
DonnieBLT
left a comment
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.
Does this work? Can you please update it check the new label logic?
WalkthroughReplaced the unconditional unassign path with a pre-check that searches for an open PR authored by the assignee mentioning the issue; if found, unassign is skipped. If no PR is found, the code now only unassigns when the issue has no labels. Removed the unconditional removal of the Changes
Sequence Diagram(s)sequenceDiagram
participant Workflow
participant UnassignLogic
participant PRSearch
participant LabelCheck
Workflow->>UnassignLogic: Trigger stale-assignment unassign flow
rect rgb(220,230,241)
Note over UnassignLogic: NEW — search for open PR by assignee mentioning issue
UnassignLogic->>PRSearch: Search open PRs authored by assignee mentioning issue
end
alt PR Found
PRSearch-->>UnassignLogic: Open PR exists
Note over UnassignLogic: Log and skip unassign
else No PR Found
PRSearch-->>UnassignLogic: No open PR
UnassignLogic->>LabelCheck: Check issue labels
alt No Labels
LabelCheck-->>UnassignLogic: No labels present
Note over UnassignLogic: Remove assignee and post unassignment comment
else Labels Present
LabelCheck-->>UnassignLogic: Labels exist
Note over UnassignLogic: Skip unassign due to labels
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Knowledge base: Disabled due to 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
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 |
|
please fix the conflicts if you'd like to continue working on this |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
src/index.js(1 hunks)
🔇 Additional comments (1)
src/index.js (1)
152-154: Logic is correct but search query has limitations; runtime verification not possible in sandbox.The conditional structure properly implements the intended behavior: skip unassignment if an open PR by the assignee mentions the issue, otherwise proceed with label-based logic. The
else ifon line 154 is essential for correct flow.However, the search query (
${event.issue.number} in:body) has a limitation: it only detects issue references in PR body text, not in title, and won't catch PRs linked via GitHub's UI linking feature without explicit text reference. This may miss some linked PRs, though the standard convention ("Fixes #123") typically places references in the body.Runtime verification of the search query effectiveness cannot be completed in the sandbox environment (git repository context unavailable for
ghCLI).
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.
Pull Request Overview
This PR aims to fix a bug in the inactivity automation to prevent unassigning contributors who have created a corresponding pull request for the issue they're working on.
Key Changes:
- Added search query logic to check for open PRs by the assignee that reference the issue
- Modified the unassignment flow to skip unassigning if an open PR exists
- Changed the label-based condition logic for when to unassign
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| console.log(`Issue #${event.issue.number} does not have the "assigned" label, skipping unassign.`); | ||
| if (searchResult.data.total_count > 0) { | ||
| console.log(`Issue #${event.issue.number} has an open PR by ${event.issue.assignee.login}, skipping unassign.`); | ||
| } else if (issueDetails.data.labels.length === 0) { |
Copilot
AI
Nov 16, 2025
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.
Bug: The logic is incorrect - this condition checks if labels.length === 0 (no labels), but the else branch at line 331 says "has labels, skipping unassign". This means the code will only unassign when there are NO labels, which contradicts the original logic that checked for the presence of the "assigned" label specifically (line 295). The logic should check whether to proceed after label removal, not based on total label count.
| } else if (issueDetails.data.labels.length === 0) { | |
| } else if (!issueDetails.data.labels.some(label => label.name === "assigned")) { |
| await octokit.issues.removeAssignees({ | ||
| owner, | ||
| repo, | ||
| issue_number: event.issue.number, | ||
| assignees: [event.issue.assignee.login], | ||
| }); |
Copilot
AI
Nov 16, 2025
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.
Bug: Duplicate unassignment operation. The assignee is already removed at lines 298-303, so this second call to removeAssignees is redundant and will fail or do nothing since the assignee has already been removed.
| await octokit.issues.removeAssignees({ | |
| owner, | |
| repo, | |
| issue_number: event.issue.number, | |
| assignees: [event.issue.assignee.login], | |
| }); |
|
|
||
| await octokit.issues.removeAssignees({ | ||
| owner, | ||
| repo, |
Copilot
AI
Nov 16, 2025
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.
Bug: Variable inconsistency - repo should be repoName to match the rest of the codebase. This variable is used consistently as repoName in lines 300, 291, 267, 253.
| // Add a comment about unassignment | ||
| await octokit.issues.createComment({ | ||
| owner, | ||
| repo, |
Copilot
AI
Nov 16, 2025
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.
Bug: Variable inconsistency - repo should be repoName to match the rest of the codebase.
| await octokit.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number: event.issue.number, | ||
| body: `⏰ This issue has been automatically unassigned due to 24 hours of inactivity. | ||
| The issue is now available for anyone to work on again.` | ||
| }); |
Copilot
AI
Nov 16, 2025
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.
The removeLabel call for the "assigned" label has been removed from the original code. If the label-based tracking system is still being used, the label should be removed when unassigning the contributor to maintain consistency.
| const query = `type:pr state:open repo:${owner}/${repo} author:${event.issue.assignee.login} ${event.issue.number} in:body`; | ||
| const searchResult = await octokit.search.issuesAndPullRequests({ | ||
| q: query | ||
| }); |
Copilot
AI
Nov 16, 2025
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.
This code duplicates logic that already exists above (lines 272-282). The timeline events check for cross-referenced PRs should be sufficient. Adding a separate search query here creates redundant checks and makes the code harder to maintain. Consider removing this duplicate check or consolidating the PR detection logic.
| repo: repoName, | ||
| issue_number: event.issue.number, | ||
| name: "assigned" | ||
| const query = `type:pr state:open repo:${owner}/${repo} author:${event.issue.assignee.login} ${event.issue.number} in:body`; |
Copilot
AI
Nov 16, 2025
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.
Bug: Variable inconsistency - repo is used here but should be repoName to match the variable used throughout the rest of this function (see lines 300, 291, 267, 253, etc.). This will cause a reference error.
| const query = `type:pr state:open repo:${owner}/${repo} author:${event.issue.assignee.login} ${event.issue.number} in:body`; | |
| const query = `type:pr state:open repo:${owner}/${repoName} author:${event.issue.assignee.login} ${event.issue.number} in:body`; |
I'll ready the PR once successfully tested the proposed changes in a test repository. I'll add screenshots for the same.
Summary by CodeRabbit