From: Jean Flach Date: Thu, 5 Apr 2018 08:47:17 +0000 (+0200) Subject: Return 500 when no api action is successful X-Git-Tag: v2.9.0~101^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b291be98904045a5f3accba6d3a66ba190bced8;p=icinga2 Return 500 when no api action is successful fixes #5095 --- diff --git a/lib/remote/actionshandler.cpp b/lib/remote/actionshandler.cpp index a8b31fc10..9358f7b32 100644 --- a/lib/remote/actionshandler.cpp +++ b/lib/remote/actionshandler.cpp @@ -91,11 +91,19 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques } } + response.SetStatus(500, "No action executed successfully"); + + for (const Dictionary::Ptr& res : results) { + if (res->Contains("result") && res->Get("result") == 200) { + response.SetStatus(200, "OK"); + break; + } + } + Dictionary::Ptr result = new Dictionary({ { "results", new Array(std::move(results)) } }); - response.SetStatus(200, "OK"); HttpUtility::SendJsonBody(response, params, result); return true;