aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.51k stars 436 forks source link

fix(auth): handle SyntaxError edge case in refresh credentials #5526

Closed nkomonen-amazon closed 2 months ago

nkomonen-amazon commented 2 months ago

Problem:

There is a small edge case where there are SOMETIMES missing fields in a SyntaxError, in this case the $response or its reason field do not exist. Due to this those cases are causing a connection to become invalid when refresh credentials fails.

Solution:

Handle the case where those fields are missing and gracefully handle them by still marking it as an AwsClientResponseError. Since we cannot extract the underlying error message, we set a custom errors message for those cases.

Now this will not cause a failed refresh credential to invalidate.


License: I confirm that my contribution is made under the terms of the Apache 2.0 license.