From c88d8339a3c7ed3d088cc5491e340653cae1bbec Mon Sep 17 00:00:00 2001 From: Jacob Wejendorp Date: Thu, 16 Dec 2021 14:40:31 +0100 Subject: [PATCH] fix: allow partial evaluation of checks in jsonfc factchecker This change should fix the entity check endpoint when some facts are missing, e.g. the retriever has not run yet. Signed-off-by: Jacob Wejendorp --- .../src/service/JsonRulesEngineFactChecker.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/tech-insights-backend-module-jsonfc/src/service/JsonRulesEngineFactChecker.ts b/plugins/tech-insights-backend-module-jsonfc/src/service/JsonRulesEngineFactChecker.ts index ae1f18a373..44087698ab 100644 --- a/plugins/tech-insights-backend-module-jsonfc/src/service/JsonRulesEngineFactChecker.ts +++ b/plugins/tech-insights-backend-module-jsonfc/src/service/JsonRulesEngineFactChecker.ts @@ -88,7 +88,13 @@ export class JsonRulesEngineFactChecker techInsightChecks.forEach(techInsightCheck => { const rule = techInsightCheck.rule; rule.name = techInsightCheck.id; - engine.addRule({ ...techInsightCheck.rule, event: noopEvent }); + // Only run checks that have all the facts available: + const hasAllFacts = techInsightCheck.factIds.every( + retrieverId => !!facts[retrieverId], + ); + if (hasAllFacts) { + engine.addRule({ ...techInsightCheck.rule, event: noopEvent }); + } }); const factValues = Object.values(facts).reduce( (acc, it) => ({ ...acc, ...it.facts }),