Skip to content

Commit

Permalink
Check for object before using the in operator
Browse files Browse the repository at this point in the history
  • Loading branch information
hetunandu committed Dec 29, 2020
1 parent 829ed8f commit e3ce750
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/client/src/workers/evaluation.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const addFunctions = (dataTree: DataTree): DataTree => {
const entity = dataTree[entityName];
if (
entity &&
_.isObject(entity) &&
"ENTITY_TYPE" in entity &&
entity.ENTITY_TYPE === ENTITY_TYPE.ACTION
) {
Expand Down Expand Up @@ -318,7 +319,7 @@ const createDependencyTree = (
const allKeys = getAllPaths(dataTree);
Object.keys(dataTree).forEach((entityKey) => {
const entity = dataTree[entityKey];
if (entity && "ENTITY_TYPE" in entity) {
if (_.isObject(entity) && "ENTITY_TYPE" in entity) {
if (
entity.ENTITY_TYPE === ENTITY_TYPE.WIDGET ||
entity.ENTITY_TYPE === ENTITY_TYPE.ACTION
Expand Down Expand Up @@ -426,7 +427,7 @@ const setTreeLoading = (
// Fetch all actions that are in loading state
Object.keys(dataTree).forEach((e) => {
const entity = dataTree[e];
if (entity && "ENTITY_TYPE" in entity) {
if (_.isObject(entity) && "ENTITY_TYPE" in entity) {
if (entity.ENTITY_TYPE === ENTITY_TYPE.WIDGET) {
widgets.push(e);
} else if (
Expand Down Expand Up @@ -827,7 +828,11 @@ export const clearPropertyCacheOfWidget = (widgetName: string) => {
const dependencyCache: Map<string, any[]> = new Map();

function isWidget(entity: DataTreeEntity): boolean {
return "ENTITY_TYPE" in entity && entity.ENTITY_TYPE === ENTITY_TYPE.WIDGET;
return (
_.isObject(entity) &&
"ENTITY_TYPE" in entity &&
entity.ENTITY_TYPE === ENTITY_TYPE.WIDGET
);
}

function validateAndParseWidgetProperty(
Expand Down

0 comments on commit e3ce750

Please sign in to comment.