-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Summary
The -AutoloadInstallations switch on Connect-GitHubAccount (alias Connect-GitHub) never triggers Connect-GitHubApp when authenticating as a GitHub App via -ClientID + -PrivateKey (or -KeyVaultKeyReference).
Root cause
In Connect-GitHubAccount.ps1 line 338:
if ($authType -eq 'App' -and $AutoloadInstallations) {
Write-Verbose 'Loading GitHub App Installation contexts...'
Connect-GitHubApp -Silent:$Silent
}The local variable $authType is only ever assigned inside the GitHub Actions token-detection block (line ~187):
if ($script:IsGitHubActions -and $PSCmdlet.ParameterSetName -notin @('GitHub App using a PrivateKey', 'GitHub App using a KeyVault Key Reference')) {
...
$authType = 'Token'
...
}For the 'GitHub App using a PrivateKey' and 'GitHub App using a KeyVault Key Reference' parameter sets, this block is explicitly skipped, so $authType remains $null. The context hashtable correctly sets $context['AuthType'] = 'APP', but the autoload check references the wrong variable ($authType instead of $context['AuthType']).
Additionally, even if the variable were correct, the comparison uses 'App' (mixed case) while the context stores 'APP' (uppercase), so a case-sensitive comparison would also fail.
Impact
-AutoloadInstallationsis effectively dead code for GitHub App authentication- Users must always explicitly call
Connect-GitHubAppafterConnect-GitHub -ClientID -PrivateKeyto get Installation Access Token contexts - This affects any automation that expects App authentication to automatically produce IAT contexts
Suggested fix
Replace:
if ($authType -eq 'App' -and $AutoloadInstallations) {With:
if ($context['AuthType'] -eq 'APP' -and $AutoloadInstallations) {Reproduction
Connect-GitHub -ClientID $clientId -PrivateKey $privateKey -AutoloadInstallations -Verbose
# Expected: Verbose output "Loading GitHub App Installation contexts..." followed by Connect-GitHubApp
# Actual: No verbose message, no IAT contexts created. Only the APP context exists.
Get-GitHubContext -ListAvailable
# Shows only the APP context, no IAT contextsMetadata
Metadata
Assignees
Labels
Type
Projects
Status