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

uv_os_get_passwd returned ENOENT if user uses AD (ldap or similar) #5277

Closed memorsolutions closed 2 months ago

memorsolutions commented 2 months ago

Problem

Both the AWS Toolkit and Amazon Q extensions produce the following error when the extension is activated and the effective user account is one that is defined externally (e.g., AD, LDAP). [error] SystemError: A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)

This appears to have been introduced by #5215 with the addition of the call to os.userInfo in getUsername (env.ts).

In such cases, the effective user ID does not have a matching entry in /etc/passwd and userInfo throw an exception. This error is discussed in several issues in other repos such as:

Might a fallback to process.env.USER be an acceptable approach for these extensions?

NOTE: Recent restructuring in https://github.com/aws/aws-toolkit-vscode/commit/c21dce155b5b3d3cd70094c843db6e8ae5b32417 appears to retain this bug.

Steps to reproduce the issue

  1. Login as a user that is synced to AD/LDAP.
  2. Install AWS Toolkit and Amazon Q
  3. See errors in ~/.config/Code/logs/<date and time>/window1/exthost/exthost.log
    
    2024-07-08 12:09:53.596 [info] ExtensionService#_doActivateExtension amazonwebservices.amazon-q-vscode, startup: false, activationEvent: 'onStartupFinished'
    2024-07-08 12:09:54.179 [error] Activating extension amazonwebservices.amazon-q-vscode failed due to an error:
    2024-07-08 12:09:54.179 [error] SystemError: A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)
        at new SystemError (node:internal/errors:257:5)
        at new NodeError (node:internal/errors:368:7)
        at Object.userInfo (node:os:365:11)
        at B (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.amazon-q-vscode-1.11.0/dist/src/extension.js:6527:34920)
        at h (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.amazon-q-vscode-1.11.0/dist/src/extension.js:6464:1883)
        at N.stop (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.amazon-q-vscode-1.11.0/dist/src/extension.js:6505:14214)
        at /home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.amazon-q-vscode-1.11.0/dist/src/extension.js:6505:15066
        at async p (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.amazon-q-vscode-1.11.0/dist/src/extension.js:6612:10284098)
        at async T (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.amazon-q-vscode-1.11.0/dist/src/extension.js:6612:10284957)
        at async c.n (/snap/code/163/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:144:6384)
        at async c.m (/snap/code/163/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:144:6347)
        at async c.l (/snap/code/163/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:144:5804)
    2024-07-08 15:05:21.445 [info] ExtensionService#_doActivateExtension amazonwebservices.aws-toolkit-vscode, startup: false, activationEvent: 'onStartupFinished'
    2024-07-08 15:05:23.110 [error] Activating extension amazonwebservices.aws-toolkit-vscode failed due to an error:
    2024-07-08 15:05:23.111 [error] SystemError: A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)
        at new SystemError (node:internal/errors:257:5)
        at new NodeError (node:internal/errors:368:7)
        at Object.userInfo (node:os:365:11)
        at Ce (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-3.12.0/dist/src/extension.js:2140:35771)
        at P (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-3.12.0/dist/src/extension.js:2060:1913)
        at I.stop (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-3.12.0/dist/src/extension.js:2117:14321)
        at /home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-3.12.0/dist/src/extension.js:2117:15179
        at async He (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-3.12.0/dist/src/extension.js:1969:6283)
        at async Ht (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-3.12.0/dist/src/extension.js:1963:41327)
        at async N (/home/jcarswell@GatorFam5.local/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-3.12.0/dist/src/extension.js:2227:9941405)
        at async c.n (/snap/code/163/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:144:6384)
        at async c.m (/snap/code/163/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:144:6347)
        at async c.l (/snap/code/163/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:144:5804)


## Expected behavior
Extensions load without error.

## System details (run `AWS: About` and/or `Amazon Q: About`)

-   OS: Ubuntu 22.04.4 (but I suspect others).
-   Visual Studio Code version: 1.91.0
-   AWS Toolkit version:  3.12.0
-   Amazon Q version: 1.11.0
justinmk3 commented 2 months ago

Thanks for the very helpful bug report! A fix is proposed in https://github.com/aws/aws-toolkit-vscode/pull/5279 . Would you mind trying it out to confirm that it fixes the issue for you?

  1. Download and extract buildArtifacts.zip
  2. In the vscode command palette, run Extensions: Install from VSIX to install the *.vsix file.
  3. Reload VSCode and perform the steps to reproduce the issue.
memorsolutions commented 2 months ago

@justinmk3 , tested and have confirmed that the errors are no longer present.

Thank you for the quick response!

hayemaxi commented 2 months ago

This request was addressed in AWS Toolkit 3.14.0 and/or Amazon Q 1.14.0!

AWS Toolkit changelog: https://github.com/aws/aws-toolkit-vscode/blob/master/packages/toolkit/CHANGELOG.md Amazon Q changelog: https://github.com/aws/aws-toolkit-vscode/blob/master/packages/amazonq/CHANGELOG.md Release artifacts: https://github.com/aws/aws-toolkit-vscode/releases