Skip to content

Commit

Permalink
#1964 Prevent failure if index is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Apr 14, 2021
1 parent 2d25f93 commit 83b8bdb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down

0 comments on commit 83b8bdb

Please sign in to comment.