From 3590bd1dee5a0e56d4d282f0a1e3cf2c8804dfa1 Mon Sep 17 00:00:00 2001 From: Nan Zhou Date: Fri, 12 Aug 2022 18:05:09 +0000 Subject: query: propogate errors for expand The existing code doesn't propogate errors of subqueries correctly. This commit corrects the behavior, so that the final response gets all error message of subqueries and the "highest priority" HTTP code. DMTF doesn't specify how expand queries handle error codes, since using subqueries is an implementation choice that we made in this project. What we did here follows existing behavior of this project, and follows the error message section of the Redfish spec; [1] https://redfish.dmtf.org/schemas/DSP0266_1.15.1.html#error-responses As for now, this commit uses the worst HTTP code among all the error code. See query_param.hpp, function |propogateErrorCode| for detailed order of the errror codes. Tested: 1. this is difficult to test, but I hijacked the code so it returns errors in TaskServices, then I verified that "/redfish/v1?$expand=." correctly returns 500 and the gets the error message set. 2. unit test so that when there are multiple errors, the final response gets a generate error message. Signed-off-by: Nan Zhou Change-Id: I0c1ebdd9015f389801db9150d687027485f1203c --- http/http_response.hpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'http/http_response.hpp') diff --git a/http/http_response.hpp b/http/http_response.hpp index dd1f37aea2..ddc808cb29 100644 --- a/http/http_response.hpp +++ b/http/http_response.hpp @@ -92,6 +92,11 @@ struct Response return *this; } + void result(unsigned v) + { + stringResponse->result(v); + } + void result(boost::beast::http::status v) { stringResponse->result(v); -- cgit v1.2.3