Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(credential-provider-node): throw cannot load credential error from credentail chain #2408

Merged
merged 5 commits into from Jun 16, 2021

Conversation

AllanZhengYP
Copy link
Contributor

@AllanZhengYP AllanZhengYP commented May 19, 2021

Resolves: #2137

Description

Previously when credential resolve chain fails to resolve the credentials, it throws the error message from the last credential provider. As a result, the error message from the credential provider chain is not helpful, when no credentials can be resolved. For example, users see Error: TimeoutError when no credentials can be resolved. This is because the last provider in the credential chain is the Instance Metadata Service, and it will timeout when running on local machine. Instead, we should indicate credential error in the message.

With this change, if none of the provider can resolve to a valid credential, the Node.js credential provider chain will throw CredentialsError: Could not load credentials from any providers just like v2.

The chain would also throw directly from any credential provider if the thrown error's tryNextLink flag is set to false. In this case users will know this is a credential error from the error name CredentialsError: XXX is wrong.

Testing

Unit tests


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Jun 2, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@3bd30bb). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2408   +/-   ##
=======================================
  Coverage        ?   59.55%           
=======================================
  Files           ?      493           
  Lines           ?    26367           
  Branches        ?     6264           
=======================================
  Hits            ?    15703           
  Misses          ?    10664           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3bd30bb...e3f341c. Read the comment docs.

packages/property-provider/src/ProviderError.spec.ts Outdated Show resolved Hide resolved
packages/property-provider/src/ProviderError.ts Outdated Show resolved Hide resolved
Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
@AllanZhengYP AllanZhengYP merged commit 5e0a46a into aws:main Jun 16, 2021
@github-actions
Copy link

github-actions bot commented Jul 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading and inconsistent error when credentials are unset
3 participants