Skip to content

Get-GitHubRepository (no params) returns only first page for authenticated user repos #643

Description

Summary

Get-GitHubRepository appears to return only a single page when called without parameters (authenticated user's repositories).

Environment

  • Host: github.com
  • Authenticated account: MariusStorhaug
  • Module: GitHub 0.43.1

Reproduction

(Get-GitHubRepository).Count

Observed:

100

Additional check:

(Get-GitHubRepository -PerPage 50).Count

Observed:

50

This strongly suggests the command returns only the first page, respecting PerPage as page size but not iterating to next pages.

Expectation

  • Calling Get-GitHubRepository with no parameters should paginate through all pages and return the full set of repositories visible to the authenticated user.

Context

  • The user profile indicates ~3.3k repositories, so a hard cap at exactly one page is likely unintended.
  • In local source (main) there appears to be pagination logic in the owner-list path, so this may be a runtime/release-path mismatch or a regression in the published module behavior.

Root cause analysis

Root cause found in Get-GitHubMyRepositories (the authenticated-user/no-parameter path used by Get-GitHubRepository).

The loop emits nodes correctly, but updates pagination state from an undefined $response variable:

$hasNextPage = $response.pageInfo.hasNextPage
$after = $response.pageInfo.endCursor

That leaves $hasNextPage false/null after the first request, so the do { ... } while ($hasNextPage) loop stops after exactly one page.

Suggested fix:

Invoke-GitHubGraphQLQuery @apiParams | ForEach-Object {
    $_.viewer.repositories.nodes | ForEach-Object {
        [GitHubRepository]::new($_)
    }
    $hasNextPage = $_.viewer.repositories.pageInfo.hasNextPage
    $after = $_.viewer.repositories.pageInfo.endCursor
}

Validated locally against the psmodule-user context with 2500+ repositories:

Import-Module '/Users/marst/.local/share/powershell/Modules/GitHub/0.43.1/GitHub.psd1' -Force
Get-GitHubRepository -Context 'psmodule-user' -PerPage 100 | Measure-Object | Select-Object -ExpandProperty Count

Result: 2985 repositories, confirming the loop now walks all pages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions