fix: Adding responseMeta in query object even when the query fails (#41216)
## 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" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/17625800361> > Commit: c3a972f13beeaef82774a8bddb28c89cf1f783f6 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=17625800361&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Thu, 11 Sep 2025 06:23:42 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
d1401ea603
commit
e1cb5d9306
|
|
@ -641,7 +641,15 @@ export default function* executePluginActionTriggerSaga(
|
||||||
} else {
|
} else {
|
||||||
throw new PluginTriggerFailureError(
|
throw new PluginTriggerFailureError(
|
||||||
createMessage(ERROR_PLUGIN_ACTION_EXECUTE, pluginActionNameToDisplay),
|
createMessage(ERROR_PLUGIN_ACTION_EXECUTE, pluginActionNameToDisplay),
|
||||||
[],
|
[
|
||||||
|
payload.body,
|
||||||
|
params,
|
||||||
|
{
|
||||||
|
isExecutionSuccess: payload.isExecutionSuccess,
|
||||||
|
statusCode: payload.statusCode,
|
||||||
|
headers: payload.headers,
|
||||||
|
},
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -531,8 +531,15 @@ export function* executeTriggerRequestSaga(
|
||||||
// a success: false is sent to reject the promise
|
// a success: false is sent to reject the promise
|
||||||
// @ts-expect-error: reason is of type string
|
// @ts-expect-error: reason is of type string
|
||||||
responsePayload.error = {
|
responsePayload.error = {
|
||||||
|
message:
|
||||||
// @ts-expect-error: reason is of type string
|
// @ts-expect-error: reason is of type string
|
||||||
message: error.responseData?.[0] || error.message,
|
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 || [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,27 @@ export default async function run(
|
||||||
* */
|
* */
|
||||||
return response[0];
|
return response[0];
|
||||||
} catch (e) {
|
} 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") {
|
if (typeof onError === "function") {
|
||||||
// TODO: Fix this the next time the file is edited
|
// TODO: Fix this the next time the file is edited
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
|
@ -76,7 +97,7 @@ export default async function run(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw e;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user