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

chore: add logging for CredentialsProviderError #1290

Merged
merged 6 commits into from
May 29, 2024

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented May 23, 2024

Enable access to the log of instantiated CredentialsProviderErrors.

In the AWS SDK with its many credential sources (default chain), the sequence through which you may end up with a certain provider in the chain is unclear, and seeing the history of thrown CredentialProviderErrors helps with both maintainer and user debugging.

Example log:

2024-05-23T20:17:57.283Z -> Not found in ENV: UA_APP_ID_ENV_NAME
2024-05-23T20:17:57.283Z -> Not found in ENV: AWS_DEFAULTS_MODE_ENV
2024-05-23T20:17:57.289Z -> Unable to find environment variable credentials.
2024-05-23T20:17:57.289Z -> Skipping SSO provider in default chain (inputs do not include SSO fields).
2024-05-23T20:17:57.296Z -> Not found in config files w/ profile [default]: UA_APP_ID_INI_NAME
2024-05-23T20:17:57.296Z -> Not found in config files w/ profile [default]: AWS_DEFAULTS_MODE_CONFIG
2024-05-23T20:17:57.297Z -> Profile some_profile could not be found or parsed in shared credentials file.
2024-05-23T20:17:57.299Z -> Profile default did not contain credential_process.
2024-05-23T20:17:57.301Z -> Web identity configuration not specified
2024-05-23T20:17:57.318Z -> Not found in ENV: ENV_ENDPOINT_URL
2024-05-23T20:17:57.318Z -> Not found in config files w/ profile [default]: CONFIG_ENDPOINT_URL
2024-05-23T20:17:57.318Z -> Not found in ENV: ENV_USE_FIPS_ENDPOINT, ENV
2024-05-23T20:17:57.318Z -> Not found in config files w/ profile [default]: CONFIG_USE_FIPS_ENDPOINT
2024-05-23T20:17:57.319Z -> Not found in ENV: ENV_USE_DUALSTACK_ENDPOINT, ENV
2024-05-23T20:17:57.319Z -> Not found in config files w/ profile [default]: CONFIG_USE_DUALSTACK_ENDPOINT
2024-05-23T20:17:57.321Z -> Not found in ENV: ENV_RETRY_MODE
2024-05-23T20:17:57.321Z -> Not found in config files w/ profile [default]: CONFIG_RETRY_MODE
2024-05-23T20:17:57.321Z -> Not found in ENV: ENV_MAX_ATTEMPTS
2024-05-23T20:17:57.321Z -> Not found in config files w/ profile [default]: CONFIG_MAX_ATTEMPTS

Example 2, debugging credential chain:

@aws-sdk/credential-provider-node defaultProvider::fromEnv
@aws-sdk/credential-provider-env - fromEnv
@smithy/property-provider -> Unable to find environment variable credentials.
@aws-sdk/credential-provider-node defaultProvider::fromSSO
@smithy/property-provider -> Skipping SSO provider in default chain (inputs do not include SSO fields).
@aws-sdk/credential-provider-node defaultProvider::fromIni
@aws-sdk/credential-provider-ini - fromIni
    default isAssumeRoleWithSourceProfile source_profile=cluster_role
@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)
@aws-sdk/credential-provider-ini - finding credential resolver using source_profile=[cluster_role]
    cluster_role isCredentialSourceProfile credential_source=EcsContainer
@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)
@aws-sdk/credential-provider-ini - finding credential resolver using profile=[cluster_role]
@aws-sdk/credential-provider-ini - credential_source is EcsContainer
@aws-sdk/credential-provider-http - fromHttp
@aws-sdk/client-sts::resolveRegion accepting first of: undefined (provider) undefined (parent client) us-east-1 (STS default)

@kuhe kuhe requested review from a team as code owners May 23, 2024 20:22
@kuhe kuhe requested a review from kstich May 23, 2024 20:22
@@ -19,7 +21,7 @@ export const fromEnv =
return config as T;
} catch (e) {
throw new CredentialsProviderError(
e.message || `Cannot load config from environment variables with getter: ${envVarSelector}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were previously logging the Function.toString() value, which is quite unreadable...

@kuhe
Copy link
Contributor Author

kuhe commented May 23, 2024

motivated by issue reported in #1288

@kuhe kuhe merged commit 1cdd3be into smithy-lang:main May 29, 2024
10 checks passed
@kuhe kuhe deleted the chore/credentials branch May 29, 2024 17:29
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request May 30, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request Jun 5, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request Jun 7, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request Jun 18, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request Jun 19, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request Jun 24, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request Jul 8, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request Jul 9, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
kuhe added a commit to kuhe/smithy-typescript that referenced this pull request Jul 15, 2024
* chore: add logging for CredentialsProviderError

* use options object

* var name clarity

* test fixes

* formatting

* set internal tag on getSelectorName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants