From 40c27d283e94616c6cef6d5ad34aaf183b6ac96c Mon Sep 17 00:00:00 2001 From: KVS85 Date: Mon, 29 Jul 2019 20:41:51 +0300 Subject: [PATCH] Bug fix 3.5/fix view creation errors (#9599) * Fix ArangoSearch view creation errors * Fix another error --- arangod/RestHandler/RestViewHandler.cpp | 25 +++++++++++++++---------- arangod/RestServer/ViewTypesFeature.cpp | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/arangod/RestHandler/RestViewHandler.cpp b/arangod/RestHandler/RestViewHandler.cpp index e63f3ccbc5..19d1e65bd3 100644 --- a/arangod/RestHandler/RestViewHandler.cpp +++ b/arangod/RestHandler/RestViewHandler.cpp @@ -166,14 +166,9 @@ void RestViewHandler::createView() { return; } - auto badParamError = [&]() -> void { - generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER, - "expecting body to be of the form {name: , type: " - ", properties: }"); - }; - if (!body.isObject()) { - badParamError(); + generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER, + "request body is not an object"); events::CreateView(_vocbase.name(), "", TRI_ERROR_BAD_PARAMETER); return; } @@ -181,10 +176,20 @@ void RestViewHandler::createView() { auto nameSlice = body.get(StaticStrings::DataSourceName); auto typeSlice = body.get(StaticStrings::DataSourceType); - if (!nameSlice.isString() || !typeSlice.isString()) { - badParamError(); + if (!nameSlice.isString()) { + generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER, + "expecting name parameter to be of the form of \"name: " + "\""); + events::CreateView(_vocbase.name(), "", TRI_ERROR_BAD_PARAMETER); + return; + } + + if (!typeSlice.isString()) { + generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER, + "expecting type parameter to be of the form of \"type: " + "\""); events::CreateView(_vocbase.name(), - (nameSlice.isString() ? nameSlice.copyString() : ""), + nameSlice.copyString(), TRI_ERROR_BAD_PARAMETER); return; } diff --git a/arangod/RestServer/ViewTypesFeature.cpp b/arangod/RestServer/ViewTypesFeature.cpp index 60f1c89791..cc41a6d35a 100644 --- a/arangod/RestServer/ViewTypesFeature.cpp +++ b/arangod/RestServer/ViewTypesFeature.cpp @@ -44,7 +44,7 @@ struct InvalidViewFactory : public arangodb::ViewFactory { return arangodb::Result( TRI_ERROR_BAD_PARAMETER, std::string( - "failure to create view without a factory for definition: ") + + "invalid type provided to create view with definition: ") + definition.toString()); } @@ -54,7 +54,7 @@ struct InvalidViewFactory : public arangodb::ViewFactory { return arangodb::Result( TRI_ERROR_BAD_PARAMETER, std::string( - "failure to instantiate view without a factory for definition: ") + + "invalid type provided to instantiate view with definition: ") + definition.toString()); } };