From 2abc23c4cfdf27e8623fea3d3fbb71ad7e25dbbe Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:35:32 -0500 Subject: [PATCH] fix(cli): requiresRefresh function does not respect null (#32666) 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* --- packages/aws-cdk/lib/api/aws-auth/provider-caching.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/api/aws-auth/provider-caching.ts b/packages/aws-cdk/lib/api/aws-auth/provider-caching.ts index f4461a7f706b2..77b7630230c22 100644 --- a/packages/aws-cdk/lib/api/aws-auth/provider-caching.ts +++ b/packages/aws-cdk/lib/api/aws-auth/provider-caching.ts @@ -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) {