Open julianbrost opened 1 year ago
I think Icinga supports multiple object modifications in a single request. Icinga then returns HTTP 200 and a set of results, each with its own status code.
This is not unreasonable, since its not obvious how to aggregate the results into one HTTP status code.
However I suggest 2 improvements:
Some API endpoints already have some logic to return helpful HTTP status codes, for example
/v1/actions/...
: https://github.com/Icinga/icinga2/blob/9be02e3f0486bd4c3aa9ecd55dda94febf5a1f79/lib/remote/actionshandler.cpp#L102-L130However, many others don't and always return 200 OK, like for example POST to
/v1/objects/...
: https://github.com/Icinga/icinga2/blob/9be02e3f0486bd4c3aa9ecd55dda94febf5a1f79/lib/remote/modifyobjecthandler.cpp#L116This leads to responses like the following when for example trying to set a non-existing attribute on some object:
git grep -F 'response.result(http::status::ok);'
shows many more instances of this and especially for error handling in API clients, it would be great that if there was an error, something else than 200 OK is returned.