Skip to content

fix(reopen): cap issue-events pagination at 10 pages and cover scoring branches - #1193

Merged
JSONbored merged 1 commit into
mainfrom
fix/pagination-cap-and-scoring-coverage
Jun 24, 2026
Merged

fix(reopen): cap issue-events pagination at 10 pages and cover scoring branches#1193
JSONbored merged 1 commit into
mainfrom
fix/pagination-cap-and-scoring-coverage

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Two follow-up fixes for recently merged PRs:

Pagination cap (#1185 follow-up): getLastCloserLogin walked 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 best lastCloser found 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 fetchUpstreamRefSha and the fail-closed guard were uncovered:

  • Catch path: SHA lookup throws (network error) → returns null → mutable-ref fallback
  • Non-string SHA: endpoint returns { sha: 42 } → typeof guard → null → mutable-ref fallback
  • Empty SHA: endpoint returns { sha: "" } → length guard → null → mutable-ref fallback
  • Prior-fallback guard: when the last-good snapshot is itself a "fallback", the freeze path must NOT fire — a fresh fallback is persisted instead

Scope

  • src/github/pr-actions.ts — add page <= 10 bound + post-loop return
  • test/unit/github-pr-actions.test.ts — cap-exit test
  • test/unit/scoring.test.ts — 4 new branch-coverage tests

Validation

  • npm run test:ci — all 3 734 tests pass

Safety

  • The pagination cap is fail-safe: the function already returns null on error and the reopen guard fails open, so the worst case is the caller treats an unknown closer as non-maintainer (allows the reopen).
  • No auth or CORS changes.

…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)
@dosubot dosubot Bot added the size:XS label Jun 24, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.80%. Comparing base (1bc3ee6) to head (a433a94).
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit f7affe7 into main Jun 24, 2026
17 checks passed
@JSONbored
JSONbored deleted the fix/pagination-cap-and-scoring-coverage branch June 24, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant