Skip to content

Commit

Permalink
Fix for defect 609923
Browse files Browse the repository at this point in the history
Updates to resolve getting a response for wrong URI in Update
Service URI (/redfish/v1/UpdateService/FirmwareInventory/)

After the fix a wrong URI that partially matches the last
characters in a valid URI now gets a 404 as shown below

curl -k -H "X-Auth-Token: $bmc_token" -X GET https://$bmc_ip/redfish/v1/UpdateService/FirmwareInventory/b8
{
  "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/b8",
  "error": {
    "@Message.ExtendedInfo": [
      {
        "@odata.type": "#Message.v1_1_1.Message",
        "Message": "The resource at the URI '/redfish/v1/UpdateService/FirmwareInventory/b8' was not found.",
        "MessageArgs": [
          "/redfish/v1/UpdateService/FirmwareInventory/b8"
        ],
        "MessageId": "Base.1.19.ResourceMissingAtURI",
        "MessageSeverity": "Critical",
        "Resolution": "Place a valid resource at the URI or correct the URI and resubmit the request."
      }
    ],
    "code": "Base.1.19.ResourceMissingAtURI",
    "message": "The resource at the URI '/redfish/v1/UpdateService/FirmwareInventory/b8' was not found."
  }
}
  • Loading branch information
abiasojo committed Feb 13, 2025
1 parent 7d56dde commit d3faf09
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions redfish-core/lib/update_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,13 +1227,10 @@ inline void requestRoutesSoftwareInventory(App& app)
std::shared_ptr<std::string> swId =
std::make_shared<std::string>(param);

asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
"/redfish/v1/UpdateService/FirmwareInventory/{}", *swId);

constexpr std::array<std::string_view, 1> interfaces = {
"xyz.openbmc_project.Software.Version"};
dbus::utility::getSubTree(
"/", 0, interfaces,
"/xyz/openbmc_project/software/", 0, interfaces,
[asyncResp,
swId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
Expand All @@ -1252,16 +1249,22 @@ inline void requestRoutesSoftwareInventory(App& app)
std::string, std::vector<std::string>>>>& obj :
subtree)
{
if (!obj.first.ends_with(*swId))
sdbusplus::message::object_path path(obj.first);
std::string id = path.filename();
if (id.empty())
{
BMCWEB_LOG_DEBUG("Failed to find software id in {}",
obj.first);
continue;
}
if (id != *swId)
{
continue;
}

if (obj.second.empty())
{
continue;
}

found = true;
sw_util::getSwStatus(asyncResp, swId,
obj.second[0].first);
Expand All @@ -1281,6 +1284,9 @@ inline void requestRoutesSoftwareInventory(App& app)
*swId));
return;
}
asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
"/redfish/v1/UpdateService/FirmwareInventory/{}",
*swId);
asyncResp->res.jsonValue["@odata.type"] =
"#SoftwareInventory.v1_1_0.SoftwareInventory";
asyncResp->res.jsonValue["Name"] = "Software Inventory";
Expand Down

0 comments on commit d3faf09

Please sign in to comment.