Skip to content

fix: pagination loop termination and issue de-duplication#4

Open
Codimow wants to merge 1 commit into
alisteuber4ee1:mainfrom
Codimow:fix-pagination-loop
Open

fix: pagination loop termination and issue de-duplication#4
Codimow wants to merge 1 commit into
alisteuber4ee1:mainfrom
Codimow:fix-pagination-loop

Conversation

@Codimow

@Codimow Codimow commented Jun 16, 2026

Copy link
Copy Markdown

🎯 Fix: Pagination Loop Termination with Since Filter

Closes #1

Issue

Issue #1 — Pagination fails when fetching repository issues with the Since filter.

Root Causes Found

1. Wrong API Method Name (Critical — Code Did Not Compile)

The code called f.client.Issues.ListByRepository(...) which does not exist in go-github v57. The correct method is ListByRepo.

-issues, resp, err := f.client.Issues.ListByRepository(ctx, owner, repo, opt)
+issues, resp, err := f.client.Issues.ListByRepo(ctx, owner, repo, opt)

2. Missing go.sum

The repository was missing go.sum, preventing dependency resolution.

3. main.go Import Issues

The original main.go had a broken import alias and used an unauthenticated client despite requiring a GITHUB_TOKEN.


Files Changed

File Change
pkg/github/client.go Fixed ListByRepositoryListByRepo, added context cancellation checks, max-page safety bound, defensive perPage default, and comprehensive documentation
pkg/github/client_test.go Rewrote with 9 tests covering all acceptance criteria
main.go Fixed import alias, switched to oauth2-authenticated client
go.sum Generated via go mod tidy

Acceptance Criteria Verification

Criteria Status Test
✅ Pagination retrieves all pages with Since active PASS TestFetchIssuesWithSincePagination
✅ Loop relies on NextPage from response, not slice length PASS TestFetchIssuesWithSincePagination (page 2 returns 1 item < PerPage)
Since preserved across all paginated calls PASS TestFetchIssues_SincePreservedAcrossPages
✅ Handles empty page with NextPage link PASS TestFetchIssues_EmptyPageWithNextLink
✅ No duplicate issues PASS TestFetchIssues_NoDuplicates

Additional Quality Tests

Test What It Covers
TestFetchIssues_SinglePage Single-page response terminates in exactly 1 request
TestFetchIssues_RateLimit 403 rate-limit error propagated correctly
TestFetchIssues_ContextCancellation Cancelled context returns promptly
TestFetchIssues_DefaultPerPage perPage <= 0 defaults to 30 instead of sending invalid value
TestFetchIssues_Integration Live API test (skipped without credentials)

All tests pass ✅ | Race detector clean ✅ | go vet clean ✅

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.

🎯 Fix Pagination Loop Termination When Fetching Repository Issues with 'Since' Filter

1 participant