stmcginnis / gofish

Gofish is a Golang client library for DMTF Redfish and SNIA Swordfish interaction.
BSD 3-Clause "New" or "Revised" License
211 stars 112 forks source link

ResetBios passes nil payload #267

Closed riethm closed 4 months ago

riethm commented 1 year ago

Lenovo seems to not permit a null payload to the Bios.ResetBios endpoint:

POST /redfish/v1/Systems/1/Bios/Actions/Bios.ResetBios HTTP/1.1
Host: localhost:8345
User-Agent: gofish/1.0
Connection: close
Content-Length: 0
Accept: application/json
Authorization: Basic ...
Content-Type: application/json
If-Match: "831c5c7f4974134aaea804"
Accept-Encoding: gzip

HTTP/1.1 400 Bad Request
Connection: close
Transfer-Encoding: chunked
Cache-Control: no-store
Content-Language: en
Content-Security-Policy: default-src 'self'; connect-src *; script-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self'; child-src 'self'; object-src 'none'; frame-ancestors 'none'
Content-Type: application/json
Date: Fri, 28 Jul 2023 17:38:11 GMT
Odata-Version: 4.0
Referrer-Policy: same-origin
Server: XCC Web Server
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Xss-Protection: 1; mode=block

1d5
{"error":{"message":"A general error has occurred. See ExtendedInfo for more information.","code":"Base.1.12.GeneralError","@Message.ExtendedInfo":[{"@odata.type":"#Message.v1_1_2.Message","Message":"The request body submitted was malformed JSON and could not be parsed by the receiving service.","MessageId":"Base.1.12.MalformedJSON","Resolution":"Ensure that the request body is valid JSON and resubmit the request.","MessageSeverity":"Critical","MessageArgs":[]}]}}

0

Gofish passes a null payload, with no way to override it https://github.com/stmcginnis/gofish/blob/6e8a2909577b8424e751890a5c432352f227097b/redfish/bios.go#L180-L182

resetBiosTarget is not directly exposed either, so the only option seems to be to do an Entity.Post with hardcoded uri and custom empty payload, which seems less than ideal.

bios.Post("/redfish/v1/Systems/1/Bios/Actions/Bios.ResetBios", map[string]interface{}{})

Should the payload be changed to an empty map by default? I'm not clear if the schema for Bios.BiosReset expressly permits or prohibits a null payload.

stmcginnis commented 1 year ago

The spec isn't super clear on that. I don't have systems to test right now, but if you wanted to put up a PR that changes it to pass an empty body, maybe we can find someone that would be able to test that change against other vendors and verify for us if it's acceptable or not.

kourtneyboss commented 1 year ago

Opened PR: https://github.com/stmcginnis/gofish/pull/268

stmcginnis commented 4 months ago

Closed by #268