Created attachment 879112[details]
server.log with NPE
Description of problem:
A NPE is thrown when trying to import a template without specifying mandatory storage_domain parameter. The missing storage_domain should be caught & processed by input validation.
Version-Release number of selected component (if applicable):
rhevm-3.4.0-0.10.beta2.el6ev.noarch (av4).
rhevm-restapi-3.4.0-0.10.beta2.el6ev.noarch
How reproducible:
100%
Steps to Reproduce:
1. Have an export storage domain with a VM template on it.
2. Import the template via REST API without the storage_domain in the request:
POST /ovirt-engine/api/storagedomains/38c0db4a-cfd7-4ef9-b8ed-6942ae42841b/templates/052ba7db-4efe-46c2-b6e8-88b32226f6af/import
-~-
<action>
<cluster>
<name>Default</name>
</cluster>
</action>
-~-
3.
Actual results:
API returns:
HTTP 500 Internal Server Error
-~-
JBWEB000065: HTTP Status 500 - java.lang.NullPointerException
JBWEB000309: type JBWEB000066: Exception report
JBWEB000068: message java.lang.NullPointerException
JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.
...
...
-~-
(see attached server.log)
Expected results:
HTTP 400 Bad Request
-~-
<fault>
<reason>Incomplete parameters</reason>
<detail>Action [storage_domain.id|name] required for doImport</detail>
</fault>
-~-
Additional info:
Validation of missing 'cluster' parameter works ok:
Request body:
-~-
<action>
<storage_domain>
<name>data01</name>
</storage_domain>
</action>
-~-
Response:
HTTP 400 Bad Request
-~-
<fault>
<reason>Incomplete parameters</reason>
<detail>Action [cluster.id|name] required for doImport</detail>
</fault>
-~-
As noted on http://gerrit.ovirt.org/#/c/26127/ - the REST API should not validate this, the backend logic USED to support it:
"""
s, you should be able to have a default destination ID that should be used if a certain disk (or all of them) are missing a destination.
If this no longer happens, it's a bug in the backend command, that should be fixed there.
The validation should be either provide a default, or the full map. IMHO, this too should be done in the backend, it sounds a bit too "business-logicy" for the API layer.
"
Maor, please take a look?
Basically, ensureDomainMap should take care of this, but the domains are accessed before it's called.
Created attachment 879112 [details] server.log with NPE Description of problem: A NPE is thrown when trying to import a template without specifying mandatory storage_domain parameter. The missing storage_domain should be caught & processed by input validation. Version-Release number of selected component (if applicable): rhevm-3.4.0-0.10.beta2.el6ev.noarch (av4). rhevm-restapi-3.4.0-0.10.beta2.el6ev.noarch How reproducible: 100% Steps to Reproduce: 1. Have an export storage domain with a VM template on it. 2. Import the template via REST API without the storage_domain in the request: POST /ovirt-engine/api/storagedomains/38c0db4a-cfd7-4ef9-b8ed-6942ae42841b/templates/052ba7db-4efe-46c2-b6e8-88b32226f6af/import -~- <action> <cluster> <name>Default</name> </cluster> </action> -~- 3. Actual results: API returns: HTTP 500 Internal Server Error -~- JBWEB000065: HTTP Status 500 - java.lang.NullPointerException JBWEB000309: type JBWEB000066: Exception report JBWEB000068: message java.lang.NullPointerException JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request. ... ... -~- (see attached server.log) Expected results: HTTP 400 Bad Request -~- <fault> <reason>Incomplete parameters</reason> <detail>Action [storage_domain.id|name] required for doImport</detail> </fault> -~- Additional info: Validation of missing 'cluster' parameter works ok: Request body: -~- <action> <storage_domain> <name>data01</name> </storage_domain> </action> -~- Response: HTTP 400 Bad Request -~- <fault> <reason>Incomplete parameters</reason> <detail>Action [cluster.id|name] required for doImport</detail> </fault> -~-