Merge pull request #5497 from Icinga/fix/api-object-query-type-error

API: Fix requested attrs/joins/meta type errors in object query response
This commit is contained in:
Michael Friedrich 2017-08-15 12:52:33 +02:00 committed by GitHub
commit a43ae941b6
1 changed files with 26 additions and 3 deletions

View File

@ -123,9 +123,32 @@ bool ObjectQueryHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& re
qd.Types.insert(type->GetName());
qd.Permission = "objects/query/" + type->GetName();
Array::Ptr uattrs = params->Get("attrs");
Array::Ptr ujoins = params->Get("joins");
Array::Ptr umetas = params->Get("meta");
Array::Ptr uattrs, ujoins, umetas;
try {
uattrs = params->Get("attrs");
} catch (const std::exception&) {
HttpUtility::SendJsonError(response, 400,
"Invalid type for 'attrs' attribute specified. Array type is required.", Empty);
return true;
}
try {
ujoins = params->Get("joins");
} catch (const std::exception&) {
HttpUtility::SendJsonError(response, 400,
"Invalid type for 'joins' attribute specified. Array type is required.", Empty);
return true;
}
try {
umetas = params->Get("meta");
} catch (const std::exception&) {
HttpUtility::SendJsonError(response, 400,
"Invalid type for 'meta' attribute specified. Array type is required.", Empty);
return true;
}
bool allJoins = HttpUtility::GetLastParameter(params, "all_joins");
params->Set("type", type->GetName());