Skip to content

Commit e7993c2

Browse files
authored
Fix: handle crash in error handling of access keys page (#3051)
1 parent 3e93f7f commit e7993c2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

portal-ui/src/screens/Console/Account/Account.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { errorToHandler } from "api/errors";
4747
import HelpMenu from "../HelpMenu";
4848
import { ACCOUNT_TABLE_COLUMNS } from "./AccountUtils";
4949
import { useAppDispatch } from "store";
50-
import { ApiError, ServiceAccounts } from "api/consoleApi";
50+
import { ServiceAccounts } from "api/consoleApi";
5151
import {
5252
setErrorSnackMessage,
5353
setHelpName,
@@ -104,9 +104,12 @@ const Account = () => {
104104
const sortedRows = res.data.sort(usersSort);
105105
setRecords(sortedRows);
106106
})
107-
.catch(async (res) => {
108-
const err = (await res.json()) as ApiError;
109-
dispatch(setErrorSnackMessage(errorToHandler(err)));
107+
.catch((res) => {
108+
dispatch(
109+
setErrorSnackMessage(
110+
errorToHandler(res?.error || "Error retrieving access keys"),
111+
),
112+
);
110113
setLoading(false);
111114
});
112115
}

portal-ui/src/screens/Console/Account/AddServiceAccountScreen.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
3535
import { setErrorSnackMessage, setHelpName } from "../../../systemSlice";
3636
import { api } from "api";
3737
import { errorToHandler } from "api/errors";
38-
import { ApiError, ContentType } from "api/consoleApi";
38+
import { ContentType } from "api/consoleApi";
3939
import CodeMirrorWrapper from "../Common/FormComponents/CodeMirrorWrapper/CodeMirrorWrapper";
4040
import AddServiceAccountHelpBox from "./AddServiceAccountHelpBox";
4141
import CredentialsPrompt from "../Common/CredentialsPrompt/CredentialsPrompt";
@@ -83,10 +83,9 @@ const AddServiceAccount = () => {
8383
});
8484
})
8585

86-
.catch(async (res) => {
86+
.catch((res) => {
8787
setAddSending(false);
88-
const err = (await res.json()) as ApiError;
89-
dispatch(setErrorSnackMessage(errorToHandler(err)));
88+
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
9089
});
9190
}
9291
}, [addSending, setAddSending, dispatch, policyJSON, accessKey, secretKey]);

0 commit comments

Comments
 (0)