Skip to content

fix: paginate bulk-scan organization selection - #148

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

fix: paginate bulk-scan organization selection#148
GautamSharma99 wants to merge 2 commits 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.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator

@codex review Please review exact head 5ea8206, focusing on paginated organization discovery, case-insensitive deduplication, cancellation, pagination termination, and compatibility with the current-main merge.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 5ea8206fcb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 5ea8206fcb

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants