fix(dup-winner): order open-sibling query by number so the cap keeps the winner - #1236
Merged
Conversation
…the winner listOtherOpenPullRequests applied LIMIT(100) with no ORDER BY. The duplicate-winner adjudication elects the minimum open PR number as the cluster winner, but on a repo with >100 open PRs an unordered LIMIT could drop the true lowest-numbered sibling and mis-elect a higher-numbered PR as the winner (sparing it and closing the real winner). Order by ascending number so the 100-row window always retains the lowest open siblings.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1236 +/- ##
=======================================
Coverage 94.96% 94.96%
=======================================
Files 177 177
Lines 19772 19772
Branches 7110 7110
=======================================
Hits 18776 18776
Misses 397 397
Partials 599 599
🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes audit finding 3.9.
listOtherOpenPullRequestsappliedLIMIT(100)with noORDER BY. The duplicate-winner adjudication (isDuplicateClusterWinner) elects the minimum open PR number as the cluster winner — but on a repo with >100 open PRs, an unorderedLIMIT(rows in unspecified/insertion order) could drop the true lowest-numbered sibling, mis-electing a higher-numbered PR as winner (sparing it and closing the real winner). Now ordered by ascending number so the 100-row window always retains the lowest open siblings.Finding 3.10 (number-based election with no quality check) is the documented, owner-flag-gated design per the audit — out of scope here.
Scope
src/db/repositories.ts); no schema change; no migrationGITTENSORY_DUPLICATE_WINNER(default off); a latent-correctness fix regardlessValidation
npm run test:ci— full gate greennpm audit --audit-level=moderate— 0 vulnerabilitiesSafety
site//CNAME/lovable