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 11, 2025
1 parent 7d56dde commit f23643f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions redfish-core/lib/update_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ inline void requestRoutesSoftwareInventory(App& app)
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 +1252,21 @@ 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 Down

0 comments on commit f23643f

Please sign in to comment.