aws / aws-toolkit-visual-studio

AWS Toolkit for Visual Studio - a plugin to interact with AWS
https://aws.amazon.com/visualstudio/
Apache License 2.0
107 stars 29 forks source link

AWS Toolkit erased the content of the credentials file #454

Open TheBlueSky opened 2 months ago

TheBlueSky commented 2 months ago

Describe the bug Recently, AWS Toolkit was updated to version 1.55.2.0. I got the yellow banner in Visual Studio that suggest I configure the extension using "Extensions > AWS Toolkit > Getting Started" menu option. I did that, selected "AWS Explorer", and then clicked "Edit credentials file directly...", because I already have the required profiles configured.

AWS Toolkit, replaced the content of the credentials file with the following text:

# AWS credentials file used by AWS CLI, SDKs, and tools.
# Created by AWS Toolkit for Visual Studio. https://aws.amazon.com/visualstudio/
#
# Each [section] in this file declares a named "profile", which can be selected
# in tools like AWS Toolkit to choose which credentials you want to use.
#
# See also:
#   https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html
#   https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html

This all happens without any warning and before even configuring and saving anything.

To Reproduce

Expected behavior AWS Toolkit leave the credentials file unchanged, unless the user configures something. In such case, AWS Toolkit must append to the file, not replace it.

Screenshots N/A

Toolkit Logs N/A

Development System (please complete the following information):

Additional context I have no addition context to add, but I would like to express my frustration. Any "destructive" action must not happen without the user's knowledge. It does not make sense to assume that the file does not exist or its content do not matter.

shruti0085 commented 2 months ago

Hi @TheBlueSky,

Can you provide details about a few things for us to investigate this further?

TheBlueSky commented 2 months ago

Hi @shruti0085,

The answers to your questions are:

shruti0085 commented 1 month ago

@TheBlueSky thanks for confirming the above. We have released v1.56.0.0 of the toolkit which contains some improvements and logging related to the Edit Credentials option. Can you please install that version and try again? To avoid any risk of losing your credentials file, please keep a copy of it in a separate location before you try again. If you continue to see the issue, please attach your logs as they may offer us some additional insights.

github-actions[bot] commented 3 weeks ago

This issue is missing required information and will be closed in 7 days. To keep the issue open, leave a comment.

TheBlueSky commented 2 weeks ago

I am on v1.57.0.0, and it does not erase the credentials file any more.

However, it still adds the following text to the file, directly after the last character in the file, whether this text already in the file of not:

# AWS credentials file used by AWS CLI, SDKs, and tools.
# Created by AWS Toolkit for Visual Studio. https://aws.amazon.com/visualstudio/
#
# Each [section] in this file declares a named "profile", which can be selected
# in tools like AWS Toolkit to choose which credentials you want to use.
#
# See also:
#   https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html
#   https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html

This can make the credentials in the file invalid. For example, if the last line in my file is (without line break):

aws_session_token=someaccesstoken

It becomes:

aws_session_token=someaccesstoken# AWS credentials file used by AWS CLI, SDKs, and tools.

It will be helpful, instead of appending the text to the file "blindly", to: