fix(automation): surface malformed condition JSON instead of silently returning false
P2-46: Previous bare try/catch hid parse errors, making rules silently non-firing. Let JSON.parse throw; the caller (evaluateAutomationRules) already logs and records the failure.
This commit is contained in:
1 parent
6b391887c3
commit
4ebd98bb99
1 file changed
+2
-4
@@ -10,7 +10,8 @@ export function matchesEventConfig(
|
||||
if (sourceDepartment && ctx.department && sourceDepartment !== ctx.department) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
// Surface malformed condition JSON to the caller (automation service) so the
|
||||
// operator sees it in logs instead of silently filtering out the rule.
|
||||
const conditions = JSON.parse(configJson) as Record<string, unknown>;
|
||||
if (Object.keys(conditions).length === 0) return true;
|
||||
if (conditions.status && ctx.newStatus && conditions.status !== ctx.newStatus) return false;
|
||||
@@ -40,9 +41,6 @@ export function matchesEventConfig(
|
||||
if (conditions.projectId && ctx.projectId && conditions.projectId !== ctx.projectId) return false;
|
||||
if (conditions.agentId && ctx.agentId && conditions.agentId !== ctx.agentId) return false;
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function matchesConditions(
|
||||
|
||||
Reference in new issue
Block a user