stmcginnis/gofish

ResetBios passes nil payload

riethm opened this issue · 3 comments

riethm commented

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

gofish/redfish/bios.go

Lines 180 to 182 in 6e8a290

func (bios *Bios) ResetBios() error {
return bios.Post(bios.resetBiosTarget, nil)
}

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.

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.

Opened PR: #268

Closed by #268