Skip to content

fix: paginate bulk-scan organization selection - #148

Open
GautamSharma99 wants to merge 1 commit into
openai:mainfrom
GautamSharma99:fix/paginate-bulk-scan-organizations
Open

fix: paginate bulk-scan organization selection#148
GautamSharma99 wants to merge 1 commit into
openai:mainfrom
GautamSharma99:fix/paginate-bulk-scan-organizations

Conversation

@GautamSharma99

Copy link
Copy Markdown
Contributor

Summary

Fixes #135.

The interactive bulk-scan wizard now loads every page returned by GET /user/orgs before asking which account to scan. Previously it requested only per_page: 100, so organization memberships after the first page were silently absent from the selector.

Changes

REST pagination

Organization discovery now follows GitHub REST pagination one page at a time:

  • requests up to 100 organizations per page;
  • checks the response Link header for rel="next";
  • increments the page only when GitHub advertises another page;
  • keeps the personal-account lookup concurrent with organization discovery.

This works through the same Octokit request boundary for GitHub.com and configured GitHub Enterprise hosts.

Cancellation

The campaign abort signal is forwarded to every organization-page request. It is also checked:

  • before each page request;
  • immediately after each response;
  • after the organization and personal-account requests settle;
  • before the account prompt is shown.

Cancellation therefore stops pagination without requesting another page, opening the selector, or starting repository discovery.

Account normalization

The combined personal-account and organization list is deduplicated case-insensitively before sorting. This prevents duplicate selector entries if repeated organization memberships appear across pages while preserving the login spelling returned by GitHub.

The authenticated personal account remains available alongside all organizations.

Tests

Added a paginated REST fixture and regression coverage that verifies:

  • both organization pages are requested;
  • an organization returned only on page two appears in the selector;
  • the second-page organization can be selected and is used for GraphQL repository discovery;
  • the personal account remains in the selector;
  • duplicate organization logins across pages are shown only once;
  • cancellation after page one prevents page two from being requested;
  • cancellation prevents both the account prompt and repository discovery.

Existing single-page organization selection, GitHub Enterprise, repository pagination, authentication, and cancellation tests continue to pass.

Verification

  • pnpm run types
  • pnpm run format
  • pnpm run build
  • focused bulk-scan discovery tests
  • PATH="/opt/homebrew/bin:$PATH" pnpm run test

Full suite: 472 passed, 6 expected platform/integration skips, 0 failed.

@rajpratham1 rajpratham1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request improves bulk scan organization selection by replacing the single-page organization lookup with paginated retrieval, ensuring users with more than 100 GitHub organizations can discover all available accounts. The implementation also deduplicates organization names across pages while preserving the original casing, and checks for cancellation during pagination so aborted operations terminate cleanly before repository discovery begins. The accompanying tests verify multi-page retrieval, deduplication, pagination behavior, and cancellation handling. Based on the visible changes, the implementation addresses the stated limitation without introducing any apparent blocking issues.

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.

Bulk-scan account selection only lists the first 100 GitHub organizations

2 participants