Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Cherry Pick RBAC error fix #36248

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/client/src/sagas/ActionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,13 +795,19 @@ function* copyActionSaga(

// @ts-expect-error: type mismatch Action vs ActionCreateUpdateResponse
yield put(copyActionSuccess(payload));
} catch (e) {
} catch (e: unknown) {
const actionName = actionObject ? actionObject.name : "";
const errorMessage =
e instanceof Error
? e.message
: createMessage(ERROR_ACTION_COPY_FAIL, actionName);
yield put(
copyActionError({
...action.payload,
show: true,
error: { message: createMessage(ERROR_ACTION_COPY_FAIL, actionName) },
error: {
message: errorMessage,
},
}),
);
}
Expand Down
27 changes: 17 additions & 10 deletions app/client/src/sagas/ErrorSagas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ export function* validateResponse(
}

if (!response.responseMeta && response.status) {
throw Error(getErrorMessage(response.status, response.resourceType));
yield put({
type: ReduxActionErrorTypes.API_ERROR,
payload: {
error: new Error(
getErrorMessage(response.status, response.resourceType),
),
logToSentry,
show,
},
});
}

if (response.responseMeta.success) {
Expand Down Expand Up @@ -218,22 +227,20 @@ export interface ErrorActionPayload {
export function* errorSaga(errorAction: ReduxAction<ErrorActionPayload>) {
const effects = [ErrorEffectTypes.LOG_TO_CONSOLE];
const { payload, type } = errorAction;
const {
error,
logToDebugger,
logToSentry,
show = true,
sourceEntity,
} = payload || {};
const { error, logToDebugger, logToSentry, show, sourceEntity } =
payload || {};
const appMode: APP_MODE = yield select(getAppMode);

// "show" means show a toast. We check if the error has been asked to not been shown
// By making the default behaviour "true" we are ensuring undefined actions still pass through this check
if (show) {
// By checking undefined, undecided actions still pass through this check
if (show === undefined) {
// We want to show toasts for certain actions only so we avoid issues or if it is outside edit mode
if (shouldShowToast(type) || appMode !== APP_MODE.EDIT) {
effects.push(ErrorEffectTypes.SHOW_ALERT);
}
// If true is passed, show the error no matter what
} else if (show) {
effects.push(ErrorEffectTypes.SHOW_ALERT);
}

if (logToDebugger) {
Expand Down
Loading