]> granicus.if.org Git - icinga2/commitdiff
API: Fix error code for invalid 'attrs' type for POST requests 5044/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Wed, 1 Mar 2017 10:33:43 +0000 (11:33 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Wed, 1 Mar 2017 10:33:43 +0000 (11:33 +0100)
fixes #5043

lib/remote/modifyobjecthandler.cpp

index 3a43b2ff53ded057b274ca8dff3a8c3495da33ad..1b17a290a13600deba6d677b800bfccfe44bd70e 100644 (file)
@@ -68,7 +68,15 @@ bool ModifyObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
                return true;
        }
 
-       Dictionary::Ptr attrs = params->Get("attrs");
+       Value attrsVal = params->Get("attrs");
+
+       if (attrsVal.GetReflectionType() != Dictionary::TypeInstance) {
+               HttpUtility::SendJsonError(response, 400,
+                   "Invalid type for 'attrs' attribute specified. Dictionary type is required.", Empty);
+               return true;
+       }
+
+       Dictionary::Ptr attrs = attrsVal;
 
        Array::Ptr results = new Array();