Skip to content

fix: correct API method name and add pagination safeguards - #13

Open
pocikode wants to merge 1 commit into
alisteuber4ee1:mainfrom
pocikode:fix/pagination-loop-termination
Open

fix: correct API method name and add pagination safeguards#13
pocikode wants to merge 1 commit into
alisteuber4ee1:mainfrom
pocikode:fix/pagination-loop-termination

Conversation

@pocikode

@pocikode pocikode commented Jul 12, 2026

Copy link
Copy Markdown

Two problems here:

  1. ListByRepository does not exist in go-github v57. The method is called ListByRepo. This was a straight-up build error — the code could not compile.

  2. No guard against infinite pagination loops. If the GitHub API returns weird pagination states (which can happen with the since filter), the for {} loop would run forever.

Fixes:

  • Swapped the method name to ListByRepo
  • Added a maxPages cap (100) so the loop terminates even if something goes wrong
  • Added a ctx.Err() check per iteration so callers can cancel
  • Added a resp.NextPage == opt.Page guard for stuck pagination

The existing tests cover the happy path and rate limiting. The pagination guard is defensive — should not trigger in normal usage, but better safe than hanging.

- Fix ListByRepository -> ListByRepo (correct method name in go-github v57)
- Add maxPages guard (100) to prevent infinite pagination loops
- Add context cancellation check inside the pagination loop
- Guard against resp.NextPage == opt.Page (stuck pagination)

Fixes the build error and adds robustness against edge cases where the
GitHub API may return unexpected pagination states with the 'since' filter.
@pocikode

Copy link
Copy Markdown
Author

/claim

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