Skip to content

Commit c33bc11

Browse files
committed
fix: temp fix
1 parent 3d29bff commit c33bc11

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,32 @@ export class RuleEngine {
7070
[];
7171

7272
const ruleEngine = new RuleEngineJs(this.flags.verbose || false);
73-
const effects = (currentEvent ?
74-
ruleEngine.evaluateEvent(
75-
inputBuilder.convertEvent(currentEvent),
76-
enrollment,
77-
events,
78-
executionContext,
79-
) :
80-
ruleEngine.evaluateEnrollment(
81-
enrollment!,
82-
events,
83-
executionContext,
84-
))
85-
.map(effect => ({
86-
...Object.fromEntries(effect.ruleAction.values),
87-
action: effect.ruleAction.type,
88-
data: effect.data,
89-
})) as Array<ProgramRuleEffect>;
73+
// TODO: Remove this try/catch
74+
let effects: Array<ProgramRuleEffect>;
75+
try {
76+
effects = (currentEvent ?
77+
ruleEngine.evaluateEvent(
78+
inputBuilder.convertEvent(currentEvent),
79+
enrollment,
80+
events,
81+
executionContext,
82+
) :
83+
ruleEngine.evaluateEnrollment(
84+
enrollment!,
85+
events,
86+
executionContext,
87+
))
88+
.map(effect => ({
89+
...Object.fromEntries(effect.ruleAction.values),
90+
action: effect.ruleAction.type,
91+
data: effect.data,
92+
})) as Array<ProgramRuleEffect>;
93+
} catch (error) {
94+
// Temporary fix: catch rule engine errors (e.g., "Cannot read properties of undefined (reading 'length')")
95+
// that can occur when switching from VirtualizedSelect to SimpleSingleSelect
96+
console.warn('Rule engine evaluation error:', error);
97+
effects = [];
98+
}
9099

91100
const processRulesEffects = getRulesEffectsProcessor(this.outputConverter);
92101
return processRulesEffects({

0 commit comments

Comments
 (0)