Description of problem:
Whenever we send a request to fetch any component detail like VM, datacenter
and if the id doesnot exist then the response throws a 404. In ovirt-engine-sdk HTTPConnection.java class send method, there is a check to verify whether the reponse header has content-type xml or not. for 404 response I am sure that this is not set and hence the getHeader function returns null which throws Null pointer exception. I suspect that all non-ok responses will lead to null pointer exception instead of some other proper error message.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Using ovirt engine java sdk,
This throws NUllpointerException
Failed to Send request, throws NullPointerException
I expect that proper Exceptions to be thrown in case of wrong Ids, or any other parameter being wrong in api calls. Or atleast a response object is returned with proper error codes and messages if possible
If conn.systemService().vmsService().vmService("<vm-id>") return null because the vm does not exist for the id. A get on the vm would throw an NPE.
I suggest storing conn.systemService().vmsService().vmService("<vm-id>") in a variable and check if it is null before invoking a get on it.
Closing as not a bug
That's what I am doing right now but would have expected a better response with proper error codes and messages.This makes debugging difficult.
Last comment is somewhat not complete. conn.systemservice....vmService returns the vmservice, there is no api call involved yet and it is never null. The moment a api call is made using get method of the service, the response does not have content-type field then the send function in HttpConnection class throws NPE if vm id does not exist. proper checks should have been there in the send request.
running system services with non existing ID throws exception:
Error: HTTP response code is "404". HTTP response message is "Not Found"
Verified in java-ovirt-engine-sdk4-4.3.1-1.el7ev.noarch
This bugzilla is included in oVirt 4.3.4 release, published on June 11th 2019.
Since the problem described in this bug report should be
resolved in oVirt 4.3.4 release, it has been closed with a resolution of CURRENT RELEASE.
If the solution does not work for you, please open a new bug report.