Skip to content

Commit

Permalink
fix(middleware-user-agent): ignore errors from inspecting credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Oct 8, 2024
1 parent 089f1a4 commit 552af85
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/middleware-user-agent/src/check-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ export async function checkFeatures(
}

if (typeof config.credentials === "function") {
const credentials: AttributedAwsCredentialIdentity = await config.credentials?.();
if (credentials.accountId) {
setFeature(context, "RESOLVED_ACCOUNT_ID", "T");
}
for (const [key, value] of Object.entries(credentials.$source ?? {})) {
setFeature(context, key as keyof AwsSdkCredentialsFeatures, value);
try {
const credentials: AttributedAwsCredentialIdentity = await config.credentials?.();
if (credentials.accountId) {
setFeature(context, "RESOLVED_ACCOUNT_ID", "T");
}
for (const [key, value] of Object.entries(credentials.$source ?? {})) {
setFeature(context, key as keyof AwsSdkCredentialsFeatures, value);
}
} catch (e: unknown) {
// Sometimes config.credentials is a function but only throws
// as a way of informing users that something is missing.
// That error and any other errors are not relevant for feature-checking
// and are ignored.
}
}
}

0 comments on commit 552af85

Please sign in to comment.