aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
239 stars 79 forks source link

Set-CCRepositoryTrigger fails wiith "Repository trigger branch name list cannot be null" #146

Closed ghost closed 4 years ago

ghost commented 4 years ago

When providing an empty array with @() the command fails.

Expected Behavior

Passing in @() should allow trigger to run on all branches

Steps to Reproduce (for bugs) Example request:

Set-CCRepositoryTrigger `
            -RepositoryName "Example" `
            -Trigger @(
        @{
            Branches = @();
            CustomData = "TestData";
            DestinationArn = "arn:aws:lambda:eu-west-2:000000000000:function:Example";
            Events = "updateReference";
            Name = "ExampleTrigger";
        }
        )

Your Environment AWS.Tools.Codecommit

AWS Tools for PowerShell
Version 4.0.5.0
Copyright 2012-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET
Core Runtime Version 3.3.104.35
Copyright 2009-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Release notes: https://github.com/aws/aws-tools-for-powershell/blob/master/CHANGELOG.md

This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]

Microsoft Windows 10.0.18363 Powershell Core 7

ashishdhingra commented 4 years ago

Hi @Sean-Intellicore,

Good morning.

I was able to reproduce the issue where the following error is returned in the PowerShell console:

Set-CCRepositoryTrigger `
>>             -RepositoryName "Example" `
>>             -Trigger @(
>>         @{
>>                            
>>             CustomData = "TestData";
>>             DestinationArn = "arn:aws:lambda:us-east-2:000000000000:function:Example";
>>             Events = "updateReference";
>>             Name = "ExampleTrigger";
>>         }
>>         )
Set-CCRepositoryTrigger: Repository trigger branch name list cannot be null

Then I was going the CodeCommit API documentation for the supported scenarios. Even though the RepositoryTrigger link specifies that for branches parameter, if an empty array is specified, the trigger applies to all branches. However it also specifies the length constraint of minimum length of 1. Also the API documentation for PutRepositoryTriggers lists RepositoryTriggerBranchNameListRequiredException (At least one branch name is required, but was not specified in the trigger configuration.) as one of the errors. So looks like the CodeCommit PutRepositoryTriggers API itself doesn't allow empty branch list and the Powershell cmdlet is just returning the appropriate error.

Hence this doesn't appear to be an issue in Powershell cmdlet or .NET SDK, but merely a limitation at the CodeCommit API level. Please let me know if this provides necessary input for the issue and if this could be closed.

Thanks, Ashish

kellertk commented 4 years ago

This issue has not received a response in 2 weeks. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.