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

fix(env): getUserInfo() may fail on AD/LDAP #5279

Closed justinmk3 closed 2 months ago

justinmk3 commented 2 months ago

Problem

Both AWS Toolkit and Amazon Q fail to start when the effective user account is defined externally (e.g. by AD/LDAP). #5277

[error] SystemError: A system error occurred: uv_os_get_passwd returned ENOENT (no such file or directory)

Bisected to #5215 which calls os.userInfo in getUsername (env.ts).

When the effective user ID does not have a matching entry in /etc/passwd, userInfo throws an exception. Discussed in:

Steps to reproduce

  1. Login as a user that is synced to AD/LDAP.
  2. Install AWS Toolkit and Amazon Q
  3. Errors in ~/.config/Code/logs/<date and time>/window1/exthost/exthost.log
    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)

Solution

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

justinmk3 commented 2 months ago

changelog: https://github.com/aws/aws-toolkit-vscode/commit/10dacd932e04f5b0d377a1d516f2eef7f6ffa2a1