🪲 [Fix]: Connect-GitHubApp no longer fails when only one installation exists#568
Draft
Marius Storhaug (MariusStorhaug) wants to merge 2 commits intomainfrom
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connect-GitHubAppnow correctly connects to all available installations regardless of whether one or many exist. Previously, callingConnect-GitHubAppwhen the GitHub App had exactly one installation caused anAddRangefailure, because PowerShell returned a single object instead of an array.Fixed: Connecting with a single app installation
Connect-GitHubApp(with no filter parameters) no longer throws when your GitHub App has only one installation. The command now handles one, many, or zero installations identically.This resolves the error:
Automation workflows (e.g., Distributor sync) that call
Connect-GitHubAppwithout parameters will no longer fail on single-installation apps.Technical Details
src/functions/public/Auth/Connect-GitHubApp.ps1ArrayList.AddRange()requires anICollection. WhenGet-GitHubAppInstallationreturns a single object, PowerShell does not wrap it in an array — the bare object doesn't implementICollection, causing the call to throw.@()to guarantee an array is always passed:$selectedInstallations.AddRange(@(Get-GitHubAppInstallation -Context $Context))