Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FC-130054 : Ignore error for no matching rule #115

Merged
merged 6 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rule-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freshworks-jaya/rule-engine",
"version": "0.18.6-beta-31",
"version": "0.18.7",
"description": "Provides methods to process rules in product events in marketplace app",
"repository": "[email protected]:freshdesk/jaya-lib.git",
"main": "lib/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/rule-engine/src/RuleProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class RuleProcessor {
rules: Rule[],
integrations: Integrations,
options: RuleEngineOptions,
): Promise<Rule> {
): Promise<Rule | null> {
for (const rule of rules) {
if (this.isEnabledNonTimerRule(rule)) {
try {
Expand All @@ -240,6 +240,6 @@ export class RuleProcessor {
}
}
}
throw new Error('no matching rule');
return null;
}
}
4 changes: 2 additions & 2 deletions packages/rule-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export class RuleEngine {
// Process regular rules and get the actions of the first matching rule.
try {
const firstMatchingRule = await RuleProcessor.getFirstMatchingRule(payload.event, payload.data, rules, integrations, options);
if (firstMatchingRule.actions?.length) {
if (firstMatchingRule?.actions?.length) {
const ruleAlias = firstMatchingRule.ruleAlias || '';
await ActionExecutor.handleActions(integrations, firstMatchingRule.actions, payload, apis, customPlaceholders, options, ruleAlias);
}
} catch (err) {
if (options.enableLogger || err !== 'no matching rule') {
if (options.enableLogger) {
Utils.log(payload, integrations, ErrorCodes.FreshchatAction, { error: err as AnyJson}, LogSeverity.ALERT);
}
throw err; // Rethrow the error to be handled by the caller.
Expand Down
Loading