From e1cb5d9306258e17fdd19a0b2d5e27cb059edb70 Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Thu, 11 Sep 2025 12:34:27 +0530 Subject: [PATCH] fix: Adding `responseMeta` in query object even when the query fails (#41216) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Adding responseMeta in query object even when the query fails so the header request id can be used by the user, if needed. Fixes [#8024](https://github.com/appsmithorg/appsmith-ee/issues/8024) EE PR for tests: https://github.com/appsmithorg/appsmith-ee/pull/8149 ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: c3a972f13beeaef82774a8bddb28c89cf1f783f6 > Cypress dashboard. > Tags: `@tag.All` > Spec: >
Thu, 11 Sep 2025 06:23:42 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit * **Bug Fixes** * Improved error messages and details when plugin actions or triggers fail, providing clearer context to diagnose issues. * Surfaces underlying response data on errors (when available), enabling more informative failure feedback in the UI. * Ensures action state is updated consistently after failures (clears loading and populates data/meta when present), preventing stale or misleading states. * Standardized error handling across related flows without changing successful execution behavior. --- .../sagas/ActionExecution/PluginActionSaga.ts | 10 +++++++- app/client/src/sagas/EvaluationsSaga.ts | 11 +++++++-- .../src/workers/Evaluation/fns/actionFns.ts | 23 ++++++++++++++++++- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/app/client/src/sagas/ActionExecution/PluginActionSaga.ts b/app/client/src/sagas/ActionExecution/PluginActionSaga.ts index 9d748bb7bc..00fd7bffb4 100644 --- a/app/client/src/sagas/ActionExecution/PluginActionSaga.ts +++ b/app/client/src/sagas/ActionExecution/PluginActionSaga.ts @@ -641,7 +641,15 @@ export default function* executePluginActionTriggerSaga( } else { throw new PluginTriggerFailureError( createMessage(ERROR_PLUGIN_ACTION_EXECUTE, pluginActionNameToDisplay), - [], + [ + payload.body, + params, + { + isExecutionSuccess: payload.isExecutionSuccess, + statusCode: payload.statusCode, + headers: payload.headers, + }, + ], ); } } else { diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index dcfab0a378..f975ccd229 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -531,8 +531,15 @@ export function* executeTriggerRequestSaga( // a success: false is sent to reject the promise // @ts-expect-error: reason is of type string responsePayload.error = { - // @ts-expect-error: reason is of type string - message: error.responseData?.[0] || error.message, + message: + // @ts-expect-error: reason is of type string + error.responseData?.[0] && typeof error.responseData?.[0] === "string" + ? // @ts-expect-error: reason is of type string + error.responseData?.[0] + : // @ts-expect-error: reason is of type string + error.message, + // @ts-expect-error: responseData is of type array + responseData: error.responseData || [], }; } diff --git a/app/client/src/workers/Evaluation/fns/actionFns.ts b/app/client/src/workers/Evaluation/fns/actionFns.ts index 860c4f9d4b..7eb57b4fb1 100644 --- a/app/client/src/workers/Evaluation/fns/actionFns.ts +++ b/app/client/src/workers/Evaluation/fns/actionFns.ts @@ -68,6 +68,27 @@ export default async function run( * */ return response[0]; } catch (e) { + const error = { + // TODO: Fix this the next time the file is edited + // eslint-disable-next-line @typescript-eslint/no-explicit-any + message: (e as any).message, + }; + + // If error contains responseData, update action data and responseMeta before throwing + // @ts-expect-error: responseData is a custom property + if (e.responseData && e.responseData.length > 0) { + // @ts-expect-error: self type is not defined + const action = self[this.name] as ActionEntity; + // @ts-expect-error: responseData is array format + const responseData = e.responseData; + + if (action && responseData.length >= 3) { + action.data = responseData[0]; // error response body + action.responseMeta = responseData[2]; // { isExecutionSuccess, statusCode, headers } + action.isLoading = false; + } + } + if (typeof onError === "function") { // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -76,7 +97,7 @@ export default async function run( return; } - throw e; + throw error; } }