Return error on invalid swId
Tested:
Before:
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/invalidSwId
{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/invalidSwId",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Name": "Software Inventory",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Updateable": false
}
After:
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/invalidSwId
{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/invalidSwId",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Name": "Software Inventory",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Updateable": false,
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "/redfish/v1/$metadata#Message.v1_0_0.Message",
"Message": "The resource at the URI /redfish/v1/UpdateService/FirmwareInventory/invalidSwId was not found.",
"MessageArgs": [
"/redfish/v1/UpdateService/FirmwareInventory/invalidSwId"
],
"MessageId": "Base.1.4.0.ResourceMissingAtURI",
"Resolution": "Place a valid resource at the URI or correct the URI and resubmit the request.",
"Severity": "Critical"
}
],
"code": "Base.1.4.0.ResourceMissingAtURI",
"message": "The resource at the URI /redfish/v1/UpdateService/FirmwareInventory/invalidSwId was not found."
}
}
Change-Id: I4dbf535301d55ffff8f2a652d112e08db040d1b1
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 413e39c..7220b43 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -601,6 +601,8 @@
return;
}
+ // Ensure we find our input swId, otherwise return an error
+ bool found = false;
for (const std::pair<
std::string,
std::vector<
@@ -617,6 +619,7 @@
continue;
}
+ found = true;
fw_util::getFwStatus(asyncResp, swId, obj.second[0].first);
crow::connections::systemBus->async_method_call(
@@ -706,6 +709,14 @@
"org.freedesktop.DBus.Properties", "GetAll",
"xyz.openbmc_project.Software.Version");
}
+ if (!found)
+ {
+ BMCWEB_LOG_ERROR << "Input swID " + *swId + " not found!";
+ messages::resourceMissingAtURI(
+ asyncResp->res,
+ "/redfish/v1/UpdateService/FirmwareInventory/" + *swId);
+ return;
+ }
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",