Null check on actionObj before using it (#2190)

This commit is contained in:
Piyush Mishra 2020-12-14 21:52:45 +05:30 committed by GitHub
parent 20d15188fd
commit 7826cee7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -3,6 +3,7 @@
* */
import { get, omit } from "lodash";
import { all, select, put, takeEvery, call, take } from "redux-saga/effects";
import * as Sentry from "@sentry/react";
import {
ReduxAction,
ReduxActionErrorTypes,
@ -53,6 +54,8 @@ import PerformanceTracker, {
PerformanceTransactionName,
} from "utils/PerformanceTracker";
import { EventLocation } from "utils/AnalyticsUtil";
import { Variant } from "components/ads/common";
import { Toaster } from "components/ads/Toast";
function* syncApiParamsSaga(
actionPayload: ReduxActionWithMeta<string, { field: string }>,
@ -411,6 +414,20 @@ function* handleApiNameChangeSuccessSaga(
const { actionId } = action.payload;
const actionObj = yield select(getAction, actionId);
yield take(ReduxActionTypes.FETCH_ACTIONS_FOR_PAGE_SUCCESS);
if (!actionObj) {
// Error case, log to sentry
Toaster.show({
text: "Error occured while renaming API",
variant: Variant.danger,
});
Sentry.captureException(new Error("Error occured while renaming API"), {
extra: {
actionId: actionId,
},
});
return;
}
if (actionObj.pluginType === PLUGIN_TYPE_API) {
const params = getQueryParams();
if (params.editName) {

View File

@ -7,6 +7,7 @@ import {
call,
race,
} from "redux-saga/effects";
import * as Sentry from "@sentry/react";
import {
ReduxAction,
ReduxActionErrorTypes,
@ -40,6 +41,8 @@ import { getQueryParams } from "utils/AppsmithUtils";
import { QUERY_CONSTANT } from "constants/QueryEditorConstants";
import { isEmpty, merge } from "lodash";
import { getConfigInitialValues } from "components/formControls/utils";
import { Variant } from "components/ads/common";
import { Toaster } from "components/ads/Toast";
function* changeQuerySaga(actionPayload: ReduxAction<{ id: string }>) {
const { id } = actionPayload.payload;
@ -183,6 +186,20 @@ function* handleNameChangeSuccessSaga(
const { actionId } = action.payload;
const actionObj = yield select(getAction, actionId);
yield take(ReduxActionTypes.FETCH_ACTIONS_FOR_PAGE_SUCCESS);
if (!actionObj) {
// Error case, log to sentry
Toaster.show({
text: "Error occured while renaming query",
variant: Variant.danger,
});
Sentry.captureException(new Error("Error occured while renaming query"), {
extra: {
actionId: actionId,
},
});
return;
}
if (actionObj.pluginType === QUERY_CONSTANT) {
const params = getQueryParams();
if (params.editName) {