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

Bug 1081173

Summary: [REST API] NullPointerException thrown when importing a template without specifying storage domain
Product: [Retired] oVirt Reporter: Juan Hernández <juan.hernandez>
Component: ovirt-engine-coreAssignee: Maor <mlipchuk>
Status: CLOSED CURRENTRELEASE QA Contact: Raz Tamir <ratamir>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.4CC: acathrow, amureini, bazulay, gklein, iheim, mishka8520, mlipchuk, oramraz, pnovotny, Rhev-m-bugs, yeylon
Target Milestone: ---   
Target Release: 3.4.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: storage
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1081132 Environment:
Last Closed: 2014-05-08 13:37:30 UTC 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:    
Bug Blocks: 1081132    

Description Juan Hernández 2014-03-26 17:05:11 UTC
+++ This bug was initially created as a clone of Bug #1081132 +++

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 Maor 2014-04-24 07:35:22 UTC
Please also verify importing a VM without specifying storage domain

Comment 2 Michael Pasternak 2014-04-26 11:44:27 UTC
Maor,

whay did you merge this path? i nack'ed it before [1] as it
breaks backward compatability,

before that [storageDomain.id|name] was not mandatory and
engine was using default SD when user does not supply it (alonm confirmed that).

[1] http://gerrit.ovirt.org/#/c/26127/

Comment 3 Maor 2014-04-27 08:19:16 UTC
Hi Michael,

I was aware to the backward compatibility issue, and also discussed it with Allon and Juan.

I've checked and validated the code in the REST and engine, (also checked with git history) and I have found that the NPE was caused in the REST side at AbstractBackendStorageDomainContentResource#getDestStorageDomainId

In the REST code, there is an attempt to get the storage id although there was no storage passed in the request, that what caused the NPE.
Considering that I don't see any way the code worked without storage ever.

I have also updated the commit message to indicate that:
"...The patch should keep backward compatibility since before it, we got an
NPE, and now it is being replaced with an informative message."

Comment 4 Sandro Bonazzola 2014-05-08 13:37:30 UTC
This is an automated message

oVirt 3.4.1 has been released:
 * should fix your issue
 * should be available at your local mirror within two days.

If problems still persist, please make note of it in this bug report.