Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1081132

Summary: [REST API] NullPointerException thrown when importing a template without specifying storage domain
Product: Red Hat Enterprise Virtualization Manager Reporter: Pavel Novotny <pnovotny>
Component: ovirt-engineAssignee: Maor <mlipchuk>
Status: CLOSED CURRENTRELEASE QA Contact: Raz Tamir <ratamir>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.4.0CC: aberezin, acanan, acathrow, amureini, bazulay, gklein, iheim, lpeer, mlipchuk, oramraz, Rhev-m-bugs, scohen, yeylon
Target Milestone: ---Flags: amureini: Triaged+
Target Release: 3.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: storage
Fixed In Version: org.ovirt.engine-root-3.4.0-16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1081173 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1081173    
Bug Blocks:    
Attachments:
Description Flags
server.log with NPE none

Description Pavel Novotny 2014-03-26 16:07:45 UTC
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>
-~-

Comment 1 Allon Mureinik 2014-04-08 22:15:47 UTC
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.

Comment 2 Raz Tamir 2014-05-08 09:14:31 UTC
Verified - 
rhevm-3.4.0-0.16.rc.el6ev.noarch

    Status Code: 400 Bad Request
    Connection: close
    Content-Encoding: gzip
    Content-Length: 168
    Content-Type: application/xml
    Date: Thu, 08 May 2014 09:07:36 GMT
    Vary: Accept-Encoding

And:

<fault>
  <reason>Incomplete parameters</reason>
  <detail>
    Action [storageDomain.id|name] required for doImport
  </detail>
</fault>

Comment 3 Itamar Heim 2014-06-12 14:07:34 UTC
Closing as part of 3.4.0