Skip to content

fix: resolve pagination loop termination, API method signature, and issue deduplication with Since filter - #18

Open
yaqi-2006 wants to merge 1 commit into
alisteuber4ee1:mainfrom
yaqi-2006:main
Open

fix: resolve pagination loop termination, API method signature, and issue deduplication with Since filter#18
yaqi-2006 wants to merge 1 commit into
alisteuber4ee1:mainfrom
yaqi-2006:main

Conversation

@yaqi-2006

Copy link
Copy Markdown

Summary

Fixes issue #1: Fix Pagination Loop Termination When Fetching Repository Issues with 'Since' Filter.

Root Cause

  1. pkg/github/client.go called the non-existent method .client.Issues.ListByRepository(...) instead of ListByRepo(...).
  2. The pagination loop needed to strictly rely on *github.Response.NextPage (from GitHub's Link header) rather than returned slice lengths, preserving the Since filter across all paginated calls.
  3. Concurrent issue updates during multi-page traversal could lead to duplicate issues across pages.

Changes Made

  • API Method Correction: Updated invocation to .client.Issues.ListByRepo(ctx, owner, repo, opt).
  • Response-Driven Pagination: Handled iteration via
    esp.NextPage with defensive loop protection (�isitedPages).
  • Deduplication: Added ID-based issue deduplication (seenIDs) to prevent duplicate items from being appended.
  • Nil Safety: Added guards for nil client and response references.
  • Comprehensive Unit Tests:
    • TestFetchIssues_Pagination: Verifies standard multi-page pagination.
    • TestFetchIssues_EmptyPageWithNext: Handles empty page with a next link.
    • TestFetchIssues_Deduplication: Verifies deduplication across pages.
    • TestFetchIssues_SincePreservedAcrossPages: Verifies Since filter preservation across requests.
    • TestFetchIssues_RateLimit: Tests 403 Rate Limit error propagation.
    • TestFetchIssues_ContextCanceled: Tests context cancellation handling.
    • TestFetchIssues_NilClient: Tests nil client error handling.

Verification

  • go test -v -race ./... -> All 7 tests passed (PASS).
  • go build -v ./... -> Successfully compiled.

Closes #1

@yaqi-2006

Copy link
Copy Markdown
Author

@opire-dev claim #1

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