From 67f4c04d45f50b69c0d66b4ab0f4d3b1daf33692 Mon Sep 17 00:00:00 2001 From: YanJin Date: Tue, 24 Oct 2023 14:40:56 +0200 Subject: [PATCH] ARTESCA-9954: Fix the RoleArn is invalid issue in console --- src/js/STSClient.ts | 3 +-- src/react/DataServiceRoleProvider.tsx | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/js/STSClient.ts b/src/js/STSClient.ts index bb1b5d424..d529b7d14 100644 --- a/src/js/STSClient.ts +++ b/src/js/STSClient.ts @@ -16,8 +16,7 @@ export default class STSClient { }) { const { idToken, roleArn, RoleSessionName } = params; const p = { - DurationSeconds: 900, - // 15 minutes + DurationSeconds: 900, // 15 minutes RoleArn: roleArn, RoleSessionName, WebIdentityToken: idToken, diff --git a/src/react/DataServiceRoleProvider.tsx b/src/react/DataServiceRoleProvider.tsx index 049bd1cf8..e67bad03a 100644 --- a/src/react/DataServiceRoleProvider.tsx +++ b/src/react/DataServiceRoleProvider.tsx @@ -100,7 +100,9 @@ const DataServiceRoleProvider = ({ children }: { children: JSX.Element }) => { } else if (!storedRole && !role.roleArn && accounts.length) { setRoleState({ roleArn: accounts[0].Roles[0].Arn }); } - assumeRoleMutation.mutate(role.roleArn); + if (role.roleArn) { + assumeRoleMutation.mutate(role.roleArn); + } }, [role.roleArn, JSON.stringify(accounts)]); const { getS3Config } = useS3ConfigFromAssumeRoleResult(); @@ -108,7 +110,9 @@ const DataServiceRoleProvider = ({ children }: { children: JSX.Element }) => { const setRole = (role: { roleArn: string }) => { setRoleArnStored(role.roleArn); setRoleState(role); - assumeRoleMutation.mutate(role.roleArn); + if (role.roleArn) { + assumeRoleMutation.mutate(role.roleArn); + } }; if (role.roleArn && !assumeRoleMutation.data) {