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.47k stars 408 forks source link

vscode "Insiders": Unable to authenticate connection (ENOENT) #3422

Closed john-aws closed 1 year ago

john-aws commented 1 year ago

Problem

AWS Toolkit seems to be unable to resurrect expired connections for CodeWhisperer. Previously this worked fine - I used an AWS Builder ID specifically for CodeWhisperer authentication and I used local ~/.aws/credentials profiles for other AWS Toolkit features. Now I am unable to use CodeWhisperer.

I see the following logs:

2023-05-04 09:22:11 [ERROR]: aws.codeWhisperer.reconnect: Error: Unable to authenticate connection
     -> Error: Failed to read from "/Users/me/.aws/sso/cache/aws-toolkit-vscode-client-id-us-east-1-bccab016b709c5821826ec415d82bc7ac37085cd21d72fbd7fe1c08c733577af.json" [FSReadFailed] (key: [object Object])
     -> EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/Users/me/.aws/sso/cache/aws-toolkit-vscode-client-id-us-east-1-bccab016b709c5821826ec415d82bc7ac37085cd21d72fbd7fe1c08c733577af.json' [Unknown]

What's interesting here is that the /Users/me/.aws/sso/cache/ folder is actually empty, but I did not explicitly empty it. So, why does the AWS Toolkit extension fail completely in this scenario with no apparent attempt to treat it like a greenfield installation and simply initiate the authentication process?

I have uninstalled the AWS Toolkit VS Code extension, reloaded VS Code, and reinstalled the extension to no avail. Even after re-installation, the same 'Unable to authenticate connection' symptoms occur and new logs (with a current timestamp) indicate the same "Failed to read from ..." cause. The fact that a re-installed AWS Toolkit extension seems to be attempting to re-use configuration information from a prior installation also seems problematic to me. I would expect it to start afresh.

Expected behavior

AWS Toolkit CodeWhisperer feature would recognize that my AWS Builder ID credentials had expired, prompt me to re-authenticate, and then work as expected.

System details (run the AWS: About Toolkit command)

john-aws commented 1 year ago

Note: I have also tried the following available options but none are helpful:

When using 'Add New Connection', I select 'Use a personal email ... AWS Builder ID' which prompts me that I am 'Currently signed in with AWS Builder ID. Sign out to add another?' When I click that option to sign out, it fails with the following logs:

2023-05-04 10:47:03 [WARN]: auth: failed to logout of connection "https://view.awsapps.com/start?scopes=codecatalyst:read_write,codewhisperer:analysis,codewhisperer:completions": Error: Failed to read from "/Users/me/.aws/sso/cache/af009b1f7ddb9ae5f8834321607bbc785f21ffcb.json" [FSReadFailed] (key: https://view.awsapps.com/start?scopes=codecatalyst:read_write,codewhisperer:analysis,codewhisperer:completions)
     -> EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/Users/me/.aws/sso/cache/af009b1f7ddb9ae5f8834321607bbc785f21ffcb.json' [Unknown]
2023-05-04 10:47:03 [ERROR]: aws.auth.addConnection: Error: Failed to delete "/Users/me/.aws/sso/cache/af009b1f7ddb9ae5f8834321607bbc785f21ffcb.json" [FSDeleteFailed] (key: https://view.awsapps.com/start?scopes=codecatalyst:read_write,codewhisperer:analysis,codewhisperer:completions)
     -> EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, unlink '/Users/me/.aws/sso/cache/af009b1f7ddb9ae5f8834321607bbc785f21ffcb.json' [Unknown]
divineniiquaye commented 1 year ago

Experiencing same issue

divineniiquaye commented 1 year ago

Downgrading the version to 1.70.0 fixes the issue

justinmk3 commented 1 year ago

@divineniiquaye are you also using vscode "insiders" ? @john-aws can you try the stable release of vscode?

divineniiquaye commented 1 year ago

I'm using the insider today's release

john-aws commented 1 year ago

@justinmk3 stable VS Code release does not appear to have the same issue (so far anyway).

justinmk3 commented 1 year ago

May be related to this vscode change: https://github.com/microsoft/vscode/pull/181107

Possibly fixed by https://github.com/microsoft/vscode/pull/181526

john-aws commented 1 year ago

Confirmed that problem is no longer reproducible after VS Code Insiders update to:

Version: 1.79.0-insider Commit: 2c73d2651cc525b27fc697b820743098a204ec01