Closed GingerSnap-xx closed 10 months ago
Similar issues https://github.com/aws/aws-tools-for-powershell/issues/111 and https://github.com/aws/aws-tools-for-powershell/issues/178 reported in the past, but these were closed due to staleness. Needs to be reviewed with the team.
Hi GingerSnap-xx,
Thanks for sharing this issue.
Is this the code that I should use to reproduce this issue?
Get-EC2Tag -ErrorAction 'Ignore'
Please share the precise error message that you are receiving and trying to ignore. I should not assume that we are getting the same error message when I reproduce your steps. When I executed this command with permissions set to explicitly deny all access, I received this error message:
Get-EC2Tag: AWS was not able to validate the provided access credentials
This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.
I’m on holiday for a week. I’ll reply when I get back.
On Wed, Jul 26, 2023 at 18:14 github-actions[bot] @.***> wrote:
This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.
— Reply to this email directly, view it on GitHub https://github.com/aws/aws-tools-for-powershell/issues/327#issuecomment-1652713983, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOPDOKVWOSVCARPM5SGRFLXSGXHZANCNFSM6AAAAAAZ7DN53Q . You are receiving this because you authored the thread.Message ID: @.***>
This is also an issue with:
Get-ACCTAlternateContact -AccountId 111111111111 -AlternateContactType BILLING -ErrorVariable GetContactInfoError -ErrorAction SilentlyContinue
Example error that doesn't honor the -ErrorAction parameter - if there is no billing contact set:
ErrorRecord : No contact of the inputted alternate contact type found.
WasThrownFromThrowStatement : False
TargetSite : Void Throw()
Message : No contact of the inputted alternate contact type found.
Data : {}
InnerException : System.InvalidOperationException: No contact of the inputted alternate contact type found.
---> Amazon.Account.Model.ResourceNotFoundException: No contact of the inputted alternate contact type found.
---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
--- End of inner exception stack trace ---
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionStream(IRequestContext requestContext, IWebResponseData httpErrorResponse, HttpErrorResponseException exception, Stream responseStream)
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionAsync(IExecutionContext executionContext, HttpErrorResponseException exception)
at Amazon.Runtime.Internal.ExceptionHandler`1.HandleAsync(IExecutionContext executionContext, Exception exception)
at Amazon.Runtime.Internal.ErrorHandler.ProcessExceptionAsync(IExecutionContext executionContext, Exception exception)
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.Signer.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
at Amazon.PowerShell.Cmdlets.ACCT.GetACCTAlternateContactCmdlet.CallAWSServiceOperation(IAmazonAccount client, GetAlternateContactRequest request)
at Amazon.PowerShell.Cmdlets.ACCT.GetACCTAlternateContactCmdlet.Execute(ExecutorContext context)
--- End of inner exception stack trace ---
at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
HelpLink :
Source : System.Private.CoreLib
HResult : -2146233087
StackTrace : at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at <ScriptBlock>(Closure, FunctionContext)
Less ideal workaround, set $ErrorActionPreference to be what you want temporarily:
$ErrorActionPreference = 'SilentlyContinue'
Get-ACCTAlternateContact -AccountId 111111111111 -AlternateContactType BILLING -ErrorVariable GetContactInfoError
$ErrorActionPreference = 'Continue'
Hi Doug,
This behavior is expected. It honors the precedent set by PowerShell. The error that you have shared is a terminating error. The common parameter -ErrorAction
only applies to non-terminating errors.
-ErrorAction
Determines how the cmdlet responds to a non-terminating error from the command. This parameter works only when the command generates a non-terminating error, such as those from the Write-Error cmdlet.
Hi Doug,
This behavior is expected. It honors the precedent set by PowerShell. The error that you have shared is a terminating error. The common parameter
-ErrorAction
only applies to non-terminating errors.-ErrorAction Determines how the cmdlet responds to a non-terminating error from the command. This parameter works only when the command generates a non-terminating error, such as those from the Write-Error cmdlet.
Happy to raise a new issue so as not to sidetrack this one but my question is then: Why is this a terminating error? Most PowerShell "Get" verb cmdlets don't throw terminating errors on "not found" type errors.
E.g.:
Get-Item xxx -ErrorAction SilentlyContinue
Get-Job -Id 99 -ErrorAction SilentlyContinue
Get-Alias -Name xxx -ErrorAction SilentlyContinue
Get-Member -InputObject xxx -Name xxx -ErrorAction SilentlyContinue
Get-Module -Name xxx -ErrorAction SilentlyContinue
All of the above return non-terminating errors.
I would expect a non-terminating error and a $null return value.
@dbaileyut Changing the current behavior would be a breaking change. As you suggested, feel free to open a new issue labeled as feature-request
that the team would review and perhaps include in next major version bump.
@GingerSnap-xx Please review the issue, there is a separate feature request https://github.com/aws/aws-tools-for-powershell/issues/331 opened for team to review. Kindly confirm if it is fine to close this issue.
Yes that other issue seems to cover the problem On Fri, Aug 25, 2023 at 11:37 Ashish Dhingra @.***> wrote:
@GingerSnap-xx https://github.com/GingerSnap-xx Please review the issue, there is a separate feature request #331 https://github.com/aws/aws-tools-for-powershell/issues/331 opened for team to review. Kindly confirm if it is fine to close this issue.
— Reply to this email directly, view it on GitHub https://github.com/aws/aws-tools-for-powershell/issues/327#issuecomment-1693632242, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOPDONFGW755WQZHR5BEDTXXDIC3ANCNFSM6AAAAAAZ7DN53Q . You are receiving this because you were mentioned.Message ID: @.***>
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
GET-EC2TAG v 4.1.323 cmdlet does not honor ErrorAction parameter.
While writing an ebextension that calls Get-EC2Tag, it was deemed desirable to not write the error output to the logs as its not a problem if it cannot get the tags.
We tried making use of the ErrorAction cmdlet property and it does not suppress the error message. Per the docs: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.3
It should suppress error messages when using Ignore.
Expected Behavior
Errors in Get-EC2Tag cmdlet should suppress error messages based on the ErrorAction variable.
Current Behavior
Errors in Get-EC2Tag cmdlet does not suppress error messages based on the ErrorAction variable.
Reproduction Steps
Call Get-EC2Tag in such a way that it produces an error (lack of authorization is our current example) Error should be printed to console Call Get-EC2Tag in the same way, but with -ErrorAction Ignore Observe output
Possible Solution
Make the Get-EC2Tag cmdlet supress error messages based on ErrorAction cmdlet parameter
Additional Information/Context
No response
AWS Tools for PowerShell version used
4.1.323
PowerShell version used
5.1.17763
Operating System and version
Windows 2019 DataCenter