Skip to content

fix: paginate repositories and parse all remote URL formats#176

Open
Harshi-Shah-CS wants to merge 1 commit into
developmentfrom
CL-4192
Open

fix: paginate repositories and parse all remote URL formats#176
Harshi-Shah-CS wants to merge 1 commit into
developmentfrom
CL-4192

Conversation

@Harshi-Shah-CS

Copy link
Copy Markdown
Contributor

No description provided.

@Harshi-Shah-CS Harshi-Shah-CS requested review from a team as code owners June 10, 2026 13:44
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

Comment thread src/adapters/github.ts
const edges = repositories?.edges ?? [];
repositoriesRes.push(...map(edges, 'node'));

// Paginate while a full page is returned; the backend's hasNextPage is unreliable.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why is the backend's hasNextPage is unreliable.?

Comment thread src/adapters/github.ts
}

let repositories;
let repositories: any[] = [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we have a defined type instead of any?

Copilot AI 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.

Pull request overview

This PR updates the GitHub adapter’s repository discovery to support paginated repository fetching and to correctly parse additional GitHub remote URL formats (notably HTTPS remotes that include userinfo). This helps the CLI locate the current repo even when it’s not in the first page of repositories returned to the GitHub App.

Changes:

  • Replace the repositories GraphQL query with a paginated GitRepositories query shape (edges/pageInfo) and add variables for first/page.
  • Add recursive repository pagination in the GitHub adapter (capped at MAX_REPOSITORY_PAGES) and expand remote URL parsing to handle more HTTPS/SSH formats.
  • Extend adapter tests to cover userinfo URLs, multi-page lookup, and pagination capping; bump package version.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/graphql/queries.ts Switch repositories query to a paginated GitRepositories query with first/page variables and edges response shape.
src/adapters/github.ts Add pagination helper for repositories, update flow to select org earlier, and broaden GitHub remote URL parsing regexes.
src/adapters/github.test.ts Update mocks for new query response shape and add tests for userinfo URL parsing + pagination behaviors.
package.json Bump package version to 1.11.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/adapters/github.ts
Comment on lines +337 to 340
let repositories: any[] = [];
try {
const repositoriesQueryResponse = await this.apolloClient.query({ query: repositoriesQuery });
repositories = repositoriesQueryResponse.data.repositories;
repositories = await this.queryRepositories({ page: 1, first: 100 });
} catch {
Comment thread src/adapters/github.ts
Comment on lines +372 to +391
async queryRepositories(variables: Record<string, any>, repositoriesRes: any[] = []): Promise<any[]> {
const { data: { repositories } } = await this.apolloClient.query({
query: repositoriesQuery,
variables,
});

const edges = repositories?.edges ?? [];
repositoriesRes.push(...map(edges, 'node'));

// Paginate while a full page is returned; the backend's hasNextPage is unreliable.
if (edges.length === variables.first) {
if ((variables.page ?? 1) >= MAX_REPOSITORY_PAGES) {
return repositoriesRes;
}
variables.page = (variables.page ?? 1) + 1;
return await this.queryRepositories(variables, repositoriesRes);
}

return repositoriesRes;
}
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.

3 participants