PromucFlow_constructor/app/client/src/sagas/EvalErrorHandler.ts

283 lines
9.3 KiB
TypeScript
Raw Normal View History

chore: Add debugger CE changes (#28752) ## Description - Support Debugger logs for ModuleInputsEntity - Split the EntityLink component to add ModuleInputsEntityLink - Add a temporary icon for ModuleInputEntity in the debugger until designs are ready. (EE PR change ) CE changes related to https://github.com/appsmithorg/appsmith-ee/pull/2836 #### PR fixes following issue(s) Fixes # #### Type of change - Chore ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-11-16 13:54:48 +00:00
import type { Log, ENTITY_TYPE } from "entities/AppsmithConsole";
import { Severity } from "entities/AppsmithConsole";
import type { ConfigTree, DataTree } from "entities/DataTree/dataTreeTypes";
import {
getEntityNameAndPropertyPath,
2024-01-11 05:06:43 +00:00
isAction,
chore: Add debugger CE changes (#28752) ## Description - Support Debugger logs for ModuleInputsEntity - Split the EntityLink component to add ModuleInputsEntityLink - Add a temporary icon for ModuleInputEntity in the debugger until designs are ready. (EE PR change ) CE changes related to https://github.com/appsmithorg/appsmith-ee/pull/2836 #### PR fixes following issue(s) Fixes # #### Type of change - Chore ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-11-16 13:54:48 +00:00
isJSAction,
isWidget,
} from "@appsmith/workers/Evaluation/evaluationUtils";
import type { EvalError, EvaluationError } from "utils/DynamicBindingUtils";
import { EvalErrorTypes, getEvalErrorPath } from "utils/DynamicBindingUtils";
import { get } from "lodash";
import LOG_TYPE from "entities/AppsmithConsole/logtype";
import { select } from "redux-saga/effects";
import AppsmithConsole from "utils/AppsmithConsole";
import * as Sentry from "@sentry/react";
import AnalyticsUtil from "utils/AnalyticsUtil";
import {
createMessage,
ERROR_EVAL_ERROR_GENERIC,
JS_OBJECT_BODY_INVALID,
VALUE_IS_INVALID,
} from "@appsmith/constants/messages";
import log from "loglevel";
import type { AppState } from "@appsmith/reducers";
import { toast } from "design-system";
import { isDynamicEntity } from "@appsmith/entities/DataTree/isDynamicEntity";
import { getEntityPayloadInfo } from "@appsmith/utils/getEntityPayloadInfo";
const getDebuggerErrors = (state: AppState) => state.ui.debugger.errors;
function logLatestEvalPropertyErrors(
currentDebuggerErrors: Record<string, Log>,
dataTree: DataTree,
evalAndValidationOrder: Array<string>,
configTree: ConfigTree,
removedPaths?: Array<{ entityId: string; fullpath: string }>,
) {
const errorsToAdd = [];
const errorsToDelete = [];
const updatedDebuggerErrors: Record<string, Log> = {
...currentDebuggerErrors,
};
for (const evaluatedPath of evalAndValidationOrder) {
const { entityName, propertyPath } =
getEntityNameAndPropertyPath(evaluatedPath);
const entity = dataTree[entityName];
const entityConfig = configTree[entityName];
if (!entity || !entityConfig || !isDynamicEntity(entity)) continue;
const logBlackList = (entityConfig as any)?.logBlackList;
if (logBlackList && propertyPath in logBlackList) continue;
const allEvalErrors: EvaluationError[] = get(
entity,
getEvalErrorPath(evaluatedPath, {
fullPath: false,
isPopulated: false,
}),
[],
);
const evalErrors: EvaluationError[] = [];
const evalWarnings: EvaluationError[] = [];
for (const err of allEvalErrors) {
if (err.severity === Severity.WARNING) {
evalWarnings.push(err);
}
if (err.severity === Severity.ERROR) {
evalErrors.push(err);
}
}
const entityType = entity.ENTITY_TYPE as string;
const payloadInfo = getEntityPayloadInfo[entityType](entityConfig);
fix: Module Debugger error CE change and setter type fix (#30848) ## Description - Module Instance Debugger CE fixes - fix for setter method params type being incorrect example:- `RadioGrp1.setData(value:string)` instead of `RadioGrp1.setData(value:[?])` as we default to string when type was array. #### PR fixes following issue(s) Fixes #30872 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Enhanced type conversion functionality to support more types, improving the development experience. - **Improvements** - Added an optional `entityName` field for better entity identification. - Updated error messages for plugin actions to be more descriptive. - **Bug Fixes** - Fixed data type inconsistencies across various widgets to ensure uniformity in data handling. - **Refactor** - Refactored certain sagas for improved code maintainability and readability. - **Tests** - Adjusted widget tests to reflect the changes in data type handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-02-07 11:06:01 +00:00
const entityNameToDisplay = payloadInfo.entityName || entityName;
chore: Add debugger CE changes (#28752) ## Description - Support Debugger logs for ModuleInputsEntity - Split the EntityLink component to add ModuleInputsEntityLink - Add a temporary icon for ModuleInputEntity in the debugger until designs are ready. (EE PR change ) CE changes related to https://github.com/appsmithorg/appsmith-ee/pull/2836 #### PR fixes following issue(s) Fixes # #### Type of change - Chore ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-11-16 13:54:48 +00:00
if (!payloadInfo) continue;
const debuggerKeys = [
{
key: `${payloadInfo.id}-${propertyPath}`,
errors: evalErrors,
},
{
key: `${payloadInfo.id}-${propertyPath}-warning`,
errors: evalWarnings,
isWarning: true,
},
];
2024-01-11 05:06:43 +00:00
const httpMethod =
isAction(entity) && entity.config
? get(entity.config, "httpMethod")
: undefined;
chore: Add debugger CE changes (#28752) ## Description - Support Debugger logs for ModuleInputsEntity - Split the EntityLink component to add ModuleInputsEntityLink - Add a temporary icon for ModuleInputEntity in the debugger until designs are ready. (EE PR change ) CE changes related to https://github.com/appsmithorg/appsmith-ee/pull/2836 #### PR fixes following issue(s) Fixes # #### Type of change - Chore ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-11-16 13:54:48 +00:00
for (const { errors, isWarning, key: debuggerKey } of debuggerKeys) {
// if dataTree has error but debugger does not -> add
// if debugger has error and data tree has error -> update error
// if debugger has error but data tree does not -> remove
// if debugger or data tree does not have an error -> no change
if (errors.length) {
// TODO Rank and set the most critical error
// const error = evalErrors[0];
// Reformatting eval errors here to a format usable by the debugger
const errorMessages = errors.map((e) => {
// Error format required for the debugger
return { message: e.errorMessage, type: e.errorType };
});
const analyticsData = isWidget(entity)
? {
widgetType: entity.type,
}
: {};
fix: Module Debugger error CE change and setter type fix (#30848) ## Description - Module Instance Debugger CE fixes - fix for setter method params type being incorrect example:- `RadioGrp1.setData(value:string)` instead of `RadioGrp1.setData(value:[?])` as we default to string when type was array. #### PR fixes following issue(s) Fixes #30872 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Enhanced type conversion functionality to support more types, improving the development experience. - **Improvements** - Added an optional `entityName` field for better entity identification. - Updated error messages for plugin actions to be more descriptive. - **Bug Fixes** - Fixed data type inconsistencies across various widgets to ensure uniformity in data handling. - **Refactor** - Refactored certain sagas for improved code maintainability and readability. - **Tests** - Adjusted widget tests to reflect the changes in data type handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-02-07 11:06:01 +00:00
const logPropertyPath = !isJSAction(entity)
? propertyPath
: entityNameToDisplay;
chore: Add debugger CE changes (#28752) ## Description - Support Debugger logs for ModuleInputsEntity - Split the EntityLink component to add ModuleInputsEntityLink - Add a temporary icon for ModuleInputEntity in the debugger until designs are ready. (EE PR change ) CE changes related to https://github.com/appsmithorg/appsmith-ee/pull/2836 #### PR fixes following issue(s) Fixes # #### Type of change - Chore ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-11-16 13:54:48 +00:00
// Add or update
if (
!isJSAction(entity) ||
(isJSAction(entity) && propertyPath === "body")
) {
errorsToAdd.push({
payload: {
id: debuggerKey,
iconId: payloadInfo.iconId,
logType: isWarning ? LOG_TYPE.EVAL_WARNING : LOG_TYPE.EVAL_ERROR,
// Unless the intention is to change the message shown in the debugger please do not
// change the text shown here
text: isJSAction(entity)
? createMessage(JS_OBJECT_BODY_INVALID)
: createMessage(VALUE_IS_INVALID, propertyPath),
messages: errorMessages,
source: {
id: payloadInfo.id,
fix: Module Debugger error CE change and setter type fix (#30848) ## Description - Module Instance Debugger CE fixes - fix for setter method params type being incorrect example:- `RadioGrp1.setData(value:string)` instead of `RadioGrp1.setData(value:[?])` as we default to string when type was array. #### PR fixes following issue(s) Fixes #30872 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Enhanced type conversion functionality to support more types, improving the development experience. - **Improvements** - Added an optional `entityName` field for better entity identification. - Updated error messages for plugin actions to be more descriptive. - **Bug Fixes** - Fixed data type inconsistencies across various widgets to ensure uniformity in data handling. - **Refactor** - Refactored certain sagas for improved code maintainability and readability. - **Tests** - Adjusted widget tests to reflect the changes in data type handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-02-07 11:06:01 +00:00
name: entityNameToDisplay,
chore: Add debugger CE changes (#28752) ## Description - Support Debugger logs for ModuleInputsEntity - Split the EntityLink component to add ModuleInputsEntityLink - Add a temporary icon for ModuleInputEntity in the debugger until designs are ready. (EE PR change ) CE changes related to https://github.com/appsmithorg/appsmith-ee/pull/2836 #### PR fixes following issue(s) Fixes # #### Type of change - Chore ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-11-16 13:54:48 +00:00
type: entityType as ENTITY_TYPE,
propertyPath: logPropertyPath,
pluginType: payloadInfo.pluginType,
httpMethod,
},
analytics: analyticsData,
},
severity: isWarning ? Severity.WARNING : Severity.ERROR,
});
}
} else if (debuggerKey in updatedDebuggerErrors) {
errorsToDelete.push({ id: debuggerKey });
}
}
}
/* Clear errors for paths that are no longer in the data tree. Since the evaluation order is updated
without the paths that are no longer in the data tree, we need to keep track of the paths that
were removed during evaluations and use them to clear any errors that were previously added
for those paths.
*/
if (removedPaths?.length) {
for (const removedPath of removedPaths) {
const { entityId, fullpath } = removedPath;
const { propertyPath } = getEntityNameAndPropertyPath(fullpath);
errorsToDelete.push({ id: `${entityId}-${propertyPath}` });
}
}
// Add and delete errors from debugger
AppsmithConsole.addErrors(errorsToAdd);
AppsmithConsole.deleteErrors(errorsToDelete);
}
export function* evalErrorHandler(
errors: EvalError[],
dataTree?: DataTree,
evaluationOrder?: Array<string>,
configTree?: ConfigTree,
removedPaths?: Array<{ entityId: string; fullpath: string }>,
) {
if (dataTree && evaluationOrder && configTree) {
const currentDebuggerErrors: Record<string, Log> =
yield select(getDebuggerErrors);
// Update latest errors to the debugger
logLatestEvalPropertyErrors(
currentDebuggerErrors,
dataTree,
evaluationOrder,
configTree,
removedPaths,
);
}
errors.forEach((error) => {
switch (error.type) {
case EvalErrorTypes.CYCLICAL_DEPENDENCY_ERROR: {
if (error.context) {
// Add more info about node for the toast
const { dependencyMap, diffs, entityType, node } = error.context;
toast.show(`${error.message} Node was: ${node}`, {
kind: "error",
});
AppsmithConsole.error({
text: `${error.message} Node was: ${node}`,
});
if (error.context.logToSentry) {
// Send the generic error message to sentry for better grouping
Sentry.captureException(new Error(error.message), {
tags: {
node,
entityType,
},
extra: {
dependencyMap,
diffs,
},
// Level is warning because it could be a user error
level: Sentry.Severity.Warning,
});
}
// Log an analytics event for cyclical dep errors
AnalyticsUtil.logEvent("CYCLICAL_DEPENDENCY_ERROR", {
node,
entityType,
// Level is warning because it could be a user error
level: Sentry.Severity.Warning,
});
}
break;
}
case EvalErrorTypes.EVAL_TREE_ERROR: {
toast.show(createMessage(ERROR_EVAL_ERROR_GENERIC), {
kind: "error",
});
break;
}
case EvalErrorTypes.BAD_UNEVAL_TREE_ERROR: {
Sentry.captureException(error);
break;
}
case EvalErrorTypes.EVAL_PROPERTY_ERROR: {
log.debug(error);
break;
}
case EvalErrorTypes.CLONE_ERROR: {
/*
* https://github.com/appsmithorg/appsmith/issues/2654
* This code is being commented out to prevent these errors from going to Sentry
* till we come up with a more definitive solution to prevent this error
* Proposed solution - adding lint errors to editor to prevent these from happening
* */
// Sentry.captureException(new Error(error.message), {
// extra: {
// request: error.context,
// },
// });
break;
}
case EvalErrorTypes.PARSE_JS_ERROR: {
toast.show(`${error.message} at: ${error.context?.entity.name}`, {
kind: "error",
});
AppsmithConsole.error({
text: `${error.message} at: ${error.context?.propertyPath}`,
});
break;
}
case EvalErrorTypes.EXTRACT_DEPENDENCY_ERROR: {
Sentry.captureException(new Error(error.message), {
extra: error.context,
});
break;
}
default: {
log.debug(error);
}
}
});
}