diff --git a/app/client/src/sagas/ActionSagas.ts b/app/client/src/sagas/ActionSagas.ts index 9f16b68abd..42ab890dcf 100644 --- a/app/client/src/sagas/ActionSagas.ts +++ b/app/client/src/sagas/ActionSagas.ts @@ -129,7 +129,7 @@ import { convertToBaseParentEntityIdSelector } from "selectors/pageListSelectors import AppsmithConsole from "utils/AppsmithConsole"; import { getDynamicBindingsChangesSaga } from "utils/DynamicBindingUtils"; import { getDefaultTemplateActionConfig } from "utils/editorContextUtils"; -import { shouldBeDefined } from "utils/helpers"; +import { isEmptyKeyValue, shouldBeDefined } from "utils/helpers"; import history from "utils/history"; import { setAIPromptTriggered } from "utils/storage"; import { sendAnalyticsEventSaga } from "./AnalyticsSaga"; @@ -1029,6 +1029,12 @@ export function* setActionPropertySaga( return; } + // The Rest Api editor adds empty key value pairs in the form for display. + // We don't need to save those empty key value pairs. + if (actionObj?.pluginType === PluginType.API && isEmptyKeyValue(value)) { + return; + } + //skipSave property is added to skip API calls when the updateAction needs to be called from the caller if (!skipSave) yield put(updateAction({ id: actionId })); } diff --git a/app/client/src/utils/helpers.tsx b/app/client/src/utils/helpers.tsx index b351bc44d9..948615ea79 100644 --- a/app/client/src/utils/helpers.tsx +++ b/app/client/src/utils/helpers.tsx @@ -44,6 +44,7 @@ import { klona as klonaLite } from "klona/lite"; import { klona as klonaJson } from "klona/json"; import { startAndEndSpanForFn } from "instrumentation/generateTraces"; +import type { Property } from "entities/Action"; export const snapToGrid = ( columnWidth: number, @@ -1301,3 +1302,15 @@ export function getDomainFromEmail(email: string) { return final_domain; } + +export function isEmptyKeyValue(value: Property | Property[]): boolean { + if (Array.isArray(value)) { + return value.every((item) => isEmptyKeyValue(item)); + } + + if (typeof value === "object") { + if (value.key === "" && value.value === "") return true; + } + + return false; +}