Skip to content

Exported functions not behaving correctly with -ErrorAction SilentlyContinue #409

Open
@petervandivier

Description

@petervandivier

Issue Details

Get-GitHubTeam -TeamName foo -ErrorAction SilentlyContinue returns all teams when team foo doesn't exist.

Steps to reproduce the issue

In the below example, I want to provision BTeam. I first check to see if that team exists so that I can create it if not. Instead, I end up modifying the settings for ATeam.

$Org = 'MyOrg'
New-GitHubTeam -Org $Org -TeamName ATeam

$team = Get-GitHubTeam -Org $Org -TeamName BTeam -ErrorAction SilentlyContinue 
if($null -eq $team){
    New-GitHubTeam -Org $Org -TeamName BTeam
} else {
    Set-GitHubTeam -Org $Org -TeamName BTeam 
}

Verbose logs showing the problem

N/A

Suggested solution to the issue

Immediately exit function Get-GitHubTeam when -TeamName is specified but no match is found.

Add a return at line 193.

if ($null -eq $team)
{
$message = "Team '$TeamName' not found"
Write-Log -Message $message -Level Error
throw $message
}

Requested Assignment

  • If possible, I would like to fix this.

Operating System

OsName               : Microsoft Windows 10 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module Version

Running: 0.16.1
Installed: 0.16.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis relates to a bug in the existing module.good first issueIf you're new to the project (or to OSS in general) and you'd like to contribute, try this one.help wantedAnyone in the community is welcome to do this work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions