fix(reopen): cap issue-events pagination at 10 pages and cover scoring branches - #1193
Merged
Merged
Conversation
…g branches Pagination cap: getLastCloserLogin now exits after 10 pages (1 000 events) instead of looping indefinitely — prevents GitHub API rate exhaustion on pathologically long issue timelines. Returns the best lastCloser found within the cap; adds a test that validates the cap fires and page 11 is never fetched. Scoring coverage: add tests for the four uncovered branches in the #1192 diff: - fetchUpstreamRefSha catch path (network throw → null → mutable-ref fallback) - non-string SHA response (typeof guard → null → mutable-ref fallback) - empty SHA string (length guard → null → mutable-ref fallback) - prior fallback snapshot on second fail-closed attempt (sourceKind === "fallback" guard → does not freeze the prior fallback, bootstraps fresh defaults instead)
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 #1193 +/- ##
=======================================
Coverage 94.80% 94.80%
=======================================
Files 157 157
Lines 19090 19091 +1
Branches 6912 6912
=======================================
+ Hits 18098 18099 +1
Misses 399 399
Partials 593 593 ☔ View full report in Codecov by Harness. 🚀 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
Two follow-up fixes for recently merged PRs:
Pagination cap (#1185 follow-up):
getLastCloserLoginwalked all issue-events pages with no upper bound — on a PR with thousands of events this could exhaust the GitHub API rate limit and stall the queue processor. Cap at 10 pages (1 000 events), which covers any real PR timeline. Returns the bestlastCloserfound if the cap is reached. Adds a test asserting the cap fires and page 11 is never requested.Scoring coverage (#1192 follow-up): Four branches in
fetchUpstreamRefShaand the fail-closed guard were uncovered:{ sha: 42 }→ typeof guard → null → mutable-ref fallback{ sha: "" }→ length guard → null → mutable-ref fallback"fallback", the freeze path must NOT fire — a fresh fallback is persisted insteadScope
src/github/pr-actions.ts— addpage <= 10bound + post-loop returntest/unit/github-pr-actions.test.ts— cap-exit testtest/unit/scoring.test.ts— 4 new branch-coverage testsValidation
npm run test:ci— all 3 734 tests passSafety
nullon error and the reopen guard fails open, so the worst case is the caller treats an unknown closer as non-maintainer (allows the reopen).