Skip to content

Fix pagination limit warning condition in fetchAllSearchItems - #22

Merged
kertal merged 2 commits into
claude/github-issues-pagination-7Axlkfrom
copilot/sub-pr-21
Jan 10, 2026
Merged

Fix pagination limit warning condition in fetchAllSearchItems#22
kertal merged 2 commits into
claude/github-issues-pagination-7Axlkfrom
copilot/sub-pr-21

Conversation

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

The pagination warning condition if (page > maxPages) never evaluates to true because the while loop exits when page <= maxPages, making post-loop page at most maxPages + 1. This meant the warning never fired when hitting GitHub's 1000-item search limit.

Changes:

  • Moved totalCount from loop-scoped to function-scoped variable to track total available items
  • Changed condition from if (page > maxPages) to if (allItems.length < totalCount) to detect incomplete pagination
  • Updated warning message to show ${allItems.length} items out of ${totalCount} total for better visibility
// Before: totalCount scoped inside loop, unreachable condition
while (page <= maxPages) {
  const totalCount = searchData.total_count;
  // ...
}
if (page > maxPages) { /* never true */ }

// After: totalCount accessible, correct condition
let totalCount = 0;
while (page <= maxPages) {
  totalCount = searchData.total_count;
  // ...
}
if (allItems.length < totalCount) { /* fires when items remain */ }

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Jan 10, 2026
- Changed condition from `page > maxPages` (which would never be true) to `allItems.length < totalCount`
- Moved totalCount variable outside the loop to be accessible after loop completion
- Now properly detects when pagination limit is hit with more items remaining
- Updated warning message to show actual vs total count

Co-authored-by: kertal <463851+kertal@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jan 10, 2026

Copy link
Copy Markdown

Deploying git-vegas with  Cloudflare Pages  Cloudflare Pages

Latest commit: cad6b50
Status: ✅  Deploy successful!
Preview URL: https://5ba119ad.git-vegas.pages.dev
Branch Preview URL: https://copilot-sub-pr-21.git-vegas.pages.dev

View logs

Copilot AI changed the title [WIP] Add pagination support for fetching GitHub issues Fix pagination limit warning condition in fetchAllSearchItems Jan 10, 2026
Copilot AI requested a review from kertal January 10, 2026 14:57
@kertal
kertal marked this pull request as ready for review January 10, 2026 20:15
@kertal
kertal merged commit 3c1442b into claude/github-issues-pagination-7Axlk Jan 10, 2026
1 check passed
@kertal
kertal deleted the copilot/sub-pr-21 branch January 10, 2026 20:16
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.

2 participants