Skip to content

Commit

Permalink
fix(cli): requiresRefresh function does not respect null (#32666)
Browse files Browse the repository at this point in the history
This function should also respect `expiration: null`, I think, but also I don't believe this fixes the ultimate issue of #32653. Just a guess at this point.

The function docs are as follows:

> @param requiresRefresh
A function that will evaluate the resolved value and determine if it represents static value or one that will eventually need to be refreshed. For example, AWS credentials that have no defined expiration will never need to be refreshed, so this function would return true if the credentials resolved by the underlying provider had an expiration and false otherwise.

Since we are respecting `null` as a valid `expiration` just like `undefined` in `credentialsAboutToExpire`, we should also respect it here.

Underlying `memoize` function is this one: https://github.com/smithy-lang/smithy-typescript/blob/main/packages/property-provider/src/memoize.ts#L27

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kaizencc authored Jan 7, 2025
1 parent 946b748 commit 2abc23c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/aws-cdk/lib/api/aws-auth/provider-caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export function makeCachingProvider(provider: AwsCredentialIdentityProvider): Aw
return memoize(
provider,
credentialsAboutToExpire,
(token) => token.expiration !== undefined);
(token) => !!token.expiration,
);
}

export function credentialsAboutToExpire(token: AwsCredentialIdentity) {
Expand Down

0 comments on commit 2abc23c

Please sign in to comment.