Context
Get-GitHubRepository is used to list repositories filtered by visibility. Organization administrators and individual users rely on this to enumerate private (and internal) repositories for audit, automation, and governance workflows.
Request
When calling Get-GitHubRepository -Visibility Private (or -Visibility Internal), the command returns an empty list — even when the authenticated user has access to private repositories in their account or organization.
Reproduction steps
# Authenticated as a user with private repos
Get-GitHubRepository -Visibility Private
# Returns: (no output)
Get-GitHubRepository -Visibility Internal
# Returns: (no output)
This was reported by an organization user with access to hundreds of private repositories via the GitHub UI, and independently confirmed with a personal GitHub account that also has private repositories.
What is expected
Get-GitHubRepository -Visibility Private should return all private repositories the authenticated user has access to. Get-GitHubRepository -Owner <org> -Visibility Private should return all private repositories in the organization the user can see.
Acceptance criteria
Get-GitHubRepository -Visibility Private returns all private repositories the authenticated user can access
Get-GitHubRepository -Owner <org> -Visibility Private returns all private org repositories the user can see
- Pagination works correctly — all pages of results are returned, not just the first page
- No silent data loss when the result set exceeds one page
Environment
PSVersion: 7.5.4
GitHub module version: 0.40.4
Technical decisions
Root cause 1 — Pagination bug in Get-GitHubMyRepositories: The private function Get-GitHubMyRepositories (called when no -Owner is specified) has a pagination bug. At the end of the do...while loop, it references $response.pageInfo.hasNextPage and $response.pageInfo.endCursor, but $response is never defined — it should be $_.viewer.repositories.pageInfo.hasNextPage / .endCursor (matching the pattern used correctly in Get-GitHubRepositoryListByOwner). Because $response is $null, $hasNextPage is always falsy, causing the loop to exit after the first page. If the user has more repositories than $PerPage (default 100), the rest are silently dropped.
Root cause 2 — Default affiliation is too restrictive: Get-GitHubMyRepositories defaults the $Affiliation parameter to 'Owner'. This means Get-GitHubRepository -Visibility Private only returns private repositories the user owns — not repos from organizations (affiliation Organization_member) or collaborations (affiliation Collaborator). For the reported scenario (organization repos), the default excludes all org-owned private repos.
Fix for pagination: Replace $response.pageInfo with $_.viewer.repositories.pageInfo in Get-GitHubMyRepositories.ps1, matching the pattern already used in Get-GitHubRepositoryListByOwner.
Fix for affiliation: Consider changing the default $Affiliation to @('Owner', 'Organization_member', 'Collaborator') so that all accessible repositories are returned by default. Alternatively, keep the current default but document the behavior and let users opt in via -Affiliation. The former is more intuitive and matches user expectations.
Get-GitHubRepositoryListByOwner is correct: The org/user-specific path (Get-GitHubRepository -Owner <org>) uses correct pagination ($_.repositoryOwner.repositories.pageInfo) and passes Visibility correctly via GraphQL. No fix needed there.
Test approach: Integration tests listing private repos for the authenticated user, verifying count matches expectations. Pagination test with a low -PerPage to confirm all pages are fetched.
Implementation plan
Core fixes
Tests
Context
Get-GitHubRepositoryis used to list repositories filtered by visibility. Organization administrators and individual users rely on this to enumerate private (and internal) repositories for audit, automation, and governance workflows.Request
When calling
Get-GitHubRepository -Visibility Private(or-Visibility Internal), the command returns an empty list — even when the authenticated user has access to private repositories in their account or organization.Reproduction steps
This was reported by an organization user with access to hundreds of private repositories via the GitHub UI, and independently confirmed with a personal GitHub account that also has private repositories.
What is expected
Get-GitHubRepository -Visibility Privateshould return all private repositories the authenticated user has access to.Get-GitHubRepository -Owner <org> -Visibility Privateshould return all private repositories in the organization the user can see.Acceptance criteria
Get-GitHubRepository -Visibility Privatereturns all private repositories the authenticated user can accessGet-GitHubRepository -Owner <org> -Visibility Privatereturns all private org repositories the user can seeEnvironment
Technical decisions
Root cause 1 — Pagination bug in
Get-GitHubMyRepositories: The private functionGet-GitHubMyRepositories(called when no-Owneris specified) has a pagination bug. At the end of thedo...whileloop, it references$response.pageInfo.hasNextPageand$response.pageInfo.endCursor, but$responseis never defined — it should be$_.viewer.repositories.pageInfo.hasNextPage/.endCursor(matching the pattern used correctly inGet-GitHubRepositoryListByOwner). Because$responseis$null,$hasNextPageis always falsy, causing the loop to exit after the first page. If the user has more repositories than$PerPage(default 100), the rest are silently dropped.Root cause 2 — Default affiliation is too restrictive:
Get-GitHubMyRepositoriesdefaults the$Affiliationparameter to'Owner'. This meansGet-GitHubRepository -Visibility Privateonly returns private repositories the user owns — not repos from organizations (affiliationOrganization_member) or collaborations (affiliationCollaborator). For the reported scenario (organization repos), the default excludes all org-owned private repos.Fix for pagination: Replace
$response.pageInfowith$_.viewer.repositories.pageInfoinGet-GitHubMyRepositories.ps1, matching the pattern already used inGet-GitHubRepositoryListByOwner.Fix for affiliation: Consider changing the default
$Affiliationto@('Owner', 'Organization_member', 'Collaborator')so that all accessible repositories are returned by default. Alternatively, keep the current default but document the behavior and let users opt in via-Affiliation. The former is more intuitive and matches user expectations.Get-GitHubRepositoryListByOwneris correct: The org/user-specific path (Get-GitHubRepository -Owner <org>) uses correct pagination ($_.repositoryOwner.repositories.pageInfo) and passesVisibilitycorrectly via GraphQL. No fix needed there.Test approach: Integration tests listing private repos for the authenticated user, verifying count matches expectations. Pagination test with a low
-PerPageto confirm all pages are fetched.Implementation plan
Core fixes
Get-GitHubMyRepositories.ps1— replace$response.pageInfo.hasNextPageand$response.pageInfo.endCursorwith$_.viewer.repositories.pageInfo.hasNextPageand$_.viewer.repositories.pageInfo.endCursor$AffiliationinGet-GitHubMyRepositoriesfrom'Owner'to@('Owner', 'Organization_member', 'Collaborator')to return all accessible repos by defaultTests
Get-GitHubRepository -Visibility Privatereturns private repos-PerPagevalue to confirm all pages are fetchedGet-GitHubRepository -Owner <org> -Visibility Privatereturns org private repos