Remove InvalidUpload response code
Invalid response is something from the openbmc registry, so it's not
a valid thing to return as a response code. For this patch, remove
the generated error message, and replace the one place it's used with
internalError.
Tested: On last patch in series.
Change-Id: I8215935f00923c72fd7763645c06d0b6af73c01d
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index 7816a59..c7aeb86 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -19,6 +19,7 @@
#include <source_location>
#include <string>
#include <string_view>
+#include <utility>
// IWYU pragma: no_forward_declare crow::Response
@@ -1077,19 +1078,6 @@
const boost::urls::url_view_base& arg1);
/**
- * @brief Formats InvalidUpload message into JSON
- * Message body: "Invalid file uploaded to <arg1>: <arg2>.*"
- *
- * @param[in] arg1 Parameter of message that will replace %1 in its body.
- * @param[in] arg2 Parameter of message that will replace %2 in its body.
- *
- * @returns Message InvalidUpload formatted to JSON */
-nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2);
-
-void invalidUpload(crow::Response& res, std::string_view arg1,
- std::string_view arg2);
-
-/**
* @brief Formats InsufficientStorage message into JSON
* Message body: "Insufficient storage or memory available to complete the
* request."
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 7c2c5f4..ad6bafe 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -336,52 +336,44 @@
inline void
handleUpdateErrorType(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& url, const std::string& type)
+ const std::string& /*url*/, const std::string& type)
{
+ // NOLINTBEGIN(bugprone-branch-clone)
if (type == "xyz.openbmc_project.Software.Image.Error.UnTarFailure")
{
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid archive");
+ messages::internalError(asyncResp->res);
}
else if (type ==
"xyz.openbmc_project.Software.Image.Error.ManifestFileFailure")
{
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid manifest");
+ messages::internalError(asyncResp->res);
}
else if (type == "xyz.openbmc_project.Software.Image.Error.ImageFailure")
{
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid image format");
+ messages::internalError(asyncResp->res);
}
else if (type == "xyz.openbmc_project.Software.Version.Error.AlreadyExists")
{
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Image version already exists");
-
- redfish::messages::resourceAlreadyExists(
- asyncResp->res, "UpdateService", "Version", "uploaded version");
+ messages::resourceAlreadyExists(asyncResp->res, "UpdateService",
+ "Version", "uploaded version");
}
else if (type == "xyz.openbmc_project.Software.Image.Error.BusyFailure")
{
- redfish::messages::resourceExhaustion(asyncResp->res, url);
+ messages::internalError(asyncResp->res);
}
else if (type == "xyz.openbmc_project.Software.Version.Error.Incompatible")
{
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Incompatible image version");
+ messages::internalError(asyncResp->res);
}
else if (type ==
"xyz.openbmc_project.Software.Version.Error.ExpiredAccessKey")
{
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Update Access Key Expired");
+ messages::internalError(asyncResp->res);
}
else if (type ==
"xyz.openbmc_project.Software.Version.Error.InvalidSignature")
{
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid image signature");
+ messages::internalError(asyncResp->res);
}
else if (type ==
"xyz.openbmc_project.Software.Image.Error.InternalFailure" ||
@@ -396,6 +388,7 @@
BMCWEB_LOG_INFO("Non-Software-related Error type={}. Ignored", type);
return;
}
+ // NOLINTEND(bugprone-branch-clone)
// Clear the timer
fwAvailableTimer = nullptr;
}
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index 3c2d498..91b565f 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -32,7 +32,6 @@
#include <span>
#include <string>
#include <string_view>
-#include <utility>
namespace redfish
{
@@ -1880,41 +1879,6 @@
addMessageToErrorJson(res.jsonValue, arraySizeTooLong(arg1, arg2));
}
-void invalidUpload(crow::Response& res, std::string_view arg1,
- std::string_view arg2)
-{
- res.result(boost::beast::http::status::bad_request);
- addMessageToErrorJson(res.jsonValue, invalidUpload(arg1, arg2));
-}
-
-/**
- * @internal
- * @brief Formats Invalid File message into JSON
- *
- * See header file for more information
- * @endinternal
- */
-nlohmann::json invalidUpload(std::string_view arg1, std::string_view arg2)
-{
- std::string msg = "Invalid file uploaded to ";
- msg += arg1;
- msg += ": ";
- msg += arg2;
- msg += ".";
-
- nlohmann::json::object_t ret;
- ret["@odata.type"] = "/redfish/v1/$metadata#Message.v1_1_1.Message";
- ret["MessageId"] = "OpenBMC.0.2.InvalidUpload";
- ret["Message"] = std::move(msg);
- nlohmann::json::array_t args;
- args.emplace_back(arg1);
- args.emplace_back(arg2);
- ret["MessageArgs"] = std::move(args);
- ret["MessageSeverity"] = "Warning";
- ret["Resolution"] = "None.";
- return ret;
-}
-
nlohmann::json generateSecretKeyRequired(const boost::urls::url_view_base& arg1)
{
return getLog(redfish::registries::base::Index::generateSecretKeyRequired,
diff --git a/scripts/parse_registries.py b/scripts/parse_registries.py
index 29a40f1..194f134 100755
--- a/scripts/parse_registries.py
+++ b/scripts/parse_registries.py
@@ -272,7 +272,6 @@
"AccountModified",
"QueryParameterOutOfRange",
"PasswordChangeRequired",
- "InvalidUpload",
"InsufficientStorage",
"OperationNotAllowed",
"ArraySizeTooLong",
@@ -332,12 +331,6 @@
file, json_dict, namespace, url = entry
- # Note, this message doesn't exist in DMTF. Needs cleaned up at some point
- json_dict["Messages"]["InvalidUpload"] = {
- "Message": "Invalid file uploaded to %1: %2.*",
- "ParamTypes": ["string", "string"],
- }
-
messages = OrderedDict(
sorted(json_dict["Messages"].items(), key=get_old_index)
)
@@ -362,6 +355,7 @@
#include <source_location>
#include <string>
#include <string_view>
+#include <utility>
// IWYU pragma: no_forward_declare crow::Response