openbmc / bmcweb

A do everything Redfish, KVM, GUI, and DBus webserver for OpenBMC
Apache License 2.0
148 stars 130 forks source link

bad error message on async_method_call #245

Closed frsauvage closed 1 year ago

frsauvage commented 1 year ago

Hi,

I am able to get the good error code through dbus calls but not through bmcweb async_call

  1. How to reproduce

I wrote the following code on bmcweb server side:

crow::connections::systemBus->async_method_call(
            [asyncResp, h3mmid](const boost::system::error_code ec) {
                BMCWEB_LOG_DEBUG << "SetToFunctional response detected";
                if (ec)
                {
                    BMCWEB_LOG_ERROR << "Error while calling SetToFunctional for "<< h3mmid << " : " << ec.message();
....

I defined a errors yaml file Manager.errors.yaml :

- name: InvalidParameter
  description: >
     Allowed parameter is 0 or 1

image

I simply threw this error in dbus service

void xxx::SetToFunctional (void) {
... 
  ===>> here I log : setToFunctional -> wrong parameter: must be "0" or "1" ===> see above
  throw sdbusplus::xyz::openbmc_project::State::Rack::Manager::Error::InvalidParameter();
}
  1. See error logs (in journal)

Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "chassis_rmc.hpp":477] **SetToFunctional response detected**
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [ERROR "chassis_rmc.hpp":480] Error while calling SetToFunctional for 3 : **Input/output error**
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_response.hpp":118] calling completion handler
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_response.hpp":121] completion handler was valid
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [INFO "http_connection.hpp":410] Response: 0x1d4a668 /redfish/v1/Chassis/H3MM_H03/Actions/Oem/Atos_net/Chassis.SetToFunctional 500 keepalive=1
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "timer_queue.hpp":48] timer add inside: 0x1d1db78 7
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_connection.hpp":751] 0x1d4a668 timer added: 0x1d1db78 7
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_connection.hpp":655] 0x1d4a668 doWrite
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_connection.hpp":663] 0x1d4a668 async_write 1086 bytes
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_connection.hpp":697] 0x1d4a668 timer cancelled: 0x1d1db78 7
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_connection.hpp":681] 0x1d4a668 Clearing response
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_response.hpp":99] 0x1d4c8b8 Clearing response containers
Jan 20 12:57:27 bullhwc4e bmcweb[1266]: (2023-01-20 12:57:27) [DEBUG "http_connection.hpp":494] 0x1d4a668 doReadHeaders
Jan 20 12:57:27 bullhwc4e phosphor-chassis-state-manager[484]: **setToFunctional -> wrong parameter: must be "0" or "1"**

on dbus: I got all the good errors

busctl call xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassisRack xyz.openbmc_project.State.Rack.Manager SetToFunctional s "0"

Call failed: Error in control cooling.

root@bullhwc4e:~# busctl call xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassisRack xyz.openbmc_project.State.Rack.Manager SetToFunctional s "3"

Call failed: Allowed parameter is 0 or 1.

image

  1. Expected behavior would be to get the good (typed) message on bmcweb side in ec.message(), not Input/ouput error
edtanous commented 1 year ago

Considering this is code that is not available on master, this appears to be a question about how sdbusplus APIs are expected to work. Per the bug template, please direct questions to the openbmc discord, or mailing list. If this is a bug in bmcweb code that exists on master, please feel free to reopen.

frsauvage commented 1 year ago

@edtanous yep, I agree. I didn't know where was the issue. I solved it with sdbus forum. Thanks, Francine