From 83b8bdbe892eb24db10272c841768ce3996cc989 Mon Sep 17 00:00:00 2001 From: To-om Date: Wed, 14 Apr 2021 15:33:53 +0200 Subject: [PATCH] #1964 Prevent failure if index is not found --- .../app/org/thp/thehive/controllers/v1/AdminCtrl.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala index 77ca67817b..21637a1986 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala @@ -117,7 +117,15 @@ class AdminCtrl @Inject() ( entrypoint("Get index status") .authPermittedRoTransaction(db, Permissions.managePlatform) { _ => graph => val indices = labels.map { label => - Json.obj("name" -> label, "count" -> graph.indexCountQuery(s"""v."_label":$label""")) + val count = + try graph.indexCountQuery(s"""v."_label":$label""") + catch { + case error: Throwable => + logger.error("Index fetch error", error) + 0 + } + Json.obj("name" -> label, "count" -> count) + } val indexCount = Json.obj("name" -> "global", "indices" -> indices) Success(Results.Ok(Json.obj("index" -> Seq(indexCount))))