Context
Connect-GitHubAccount (alias Connect-GitHub) provides an -AutoloadInstallations switch intended to automatically call Connect-GitHubApp after authenticating as a GitHub App. This is important for automation scenarios where GitHub App authentication should seamlessly produce Installation Access Token (IAT) contexts without requiring a separate manual step.
Request
When authenticating as a GitHub App via -ClientID + -PrivateKey (or -KeyVaultKeyReference) with the -AutoloadInstallations switch enabled, the switch has no effect. Connect-GitHubApp is never called, and only the APP context is created — no IAT contexts are produced.
What happens
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 contexts
The user must explicitly call Connect-GitHubApp after Connect-GitHub to get IAT contexts, making the -AutoloadInstallations switch dead code.
What is expected
When -AutoloadInstallations is specified during GitHub App authentication, Connect-GitHubApp should be called automatically after the APP context is created. The user should see IAT contexts for all installations without needing a second command.
Acceptance criteria
-AutoloadInstallations triggers Connect-GitHubApp when authenticating as a GitHub App
- IAT contexts are created automatically for all app installations
- Verbose output confirms the autoload behavior
- Existing behavior for non-App authentication is unchanged
Technical decisions
Root cause: In Connect-GitHubAccount.ps1 line 338, the autoload check references a local variable $authType:
if ($authType -eq 'App' -and $AutoloadInstallations) {
Write-Verbose 'Loading GitHub App Installation contexts...'
Connect-GitHubApp -Silent:$Silent
}
The variable $authType is only assigned inside the GitHub Actions token-detection block (line ~187), which is explicitly skipped for the 'GitHub App using a PrivateKey' and 'GitHub App using a KeyVault Key Reference' parameter sets. Therefore $authType is always $null for App authentication.
Fix approach: Replace $authType with $context['AuthType'], which is correctly set to 'APP' for GitHub App parameter sets. The comparison must also use 'APP' (uppercase) to match the stored value:
if ($context['AuthType'] -eq 'APP' -and $AutoloadInstallations) {
Case sensitivity: PowerShell's -eq operator is case-insensitive by default, so 'APP' -eq 'App' evaluates to $true. However, for clarity and consistency with the stored value, use 'APP'.
Test approach: Integration test that authenticates as a GitHub App with -AutoloadInstallations and verifies that Get-GitHubContext -ListAvailable returns IAT contexts in addition to the APP context.
Implementation plan
Core fix
Tests
Context
Connect-GitHubAccount(aliasConnect-GitHub) provides an-AutoloadInstallationsswitch intended to automatically callConnect-GitHubAppafter authenticating as a GitHub App. This is important for automation scenarios where GitHub App authentication should seamlessly produce Installation Access Token (IAT) contexts without requiring a separate manual step.Request
When authenticating as a GitHub App via
-ClientID+-PrivateKey(or-KeyVaultKeyReference) with the-AutoloadInstallationsswitch enabled, the switch has no effect.Connect-GitHubAppis never called, and only the APP context is created — no IAT contexts are produced.What happens
The user must explicitly call
Connect-GitHubAppafterConnect-GitHubto get IAT contexts, making the-AutoloadInstallationsswitch dead code.What is expected
When
-AutoloadInstallationsis specified during GitHub App authentication,Connect-GitHubAppshould be called automatically after the APP context is created. The user should see IAT contexts for all installations without needing a second command.Acceptance criteria
-AutoloadInstallationstriggersConnect-GitHubAppwhen authenticating as a GitHub AppTechnical decisions
Root cause: In
Connect-GitHubAccount.ps1line 338, the autoload check references a local variable$authType:The variable
$authTypeis only assigned inside the GitHub Actions token-detection block (line ~187), which is explicitly skipped for the'GitHub App using a PrivateKey'and'GitHub App using a KeyVault Key Reference'parameter sets. Therefore$authTypeis always$nullfor App authentication.Fix approach: Replace
$authTypewith$context['AuthType'], which is correctly set to'APP'for GitHub App parameter sets. The comparison must also use'APP'(uppercase) to match the stored value:Case sensitivity: PowerShell's
-eqoperator is case-insensitive by default, so'APP' -eq 'App'evaluates to$true. However, for clarity and consistency with the stored value, use'APP'.Test approach: Integration test that authenticates as a GitHub App with
-AutoloadInstallationsand verifies thatGet-GitHubContext -ListAvailablereturns IAT contexts in addition to the APP context.Implementation plan
Core fix
Connect-GitHubAccount.ps1to use$context['AuthType']instead of$authType'APP'(the stored AuthType for GitHub App contexts)Tests
-AutoloadInstallationsproduces IAT contexts when authenticating as a GitHub App-AutoloadInstallationshas no effect for non-App authentication (regression guard)