Bug 1367411

Summary: [API] Setting custom compatibility version with bad values produces a general exception
Product: [oVirt] ovirt-engine Reporter: sefi litmanovich <slitmano>
Component: RestAPIAssignee: Sharon Gratch <sgratch>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Matyáš <pmatyas>
Severity: low Docs Contact:
Priority: low    
Version: 4.0.2.6CC: bugs, tjelinek
Target Milestone: ovirt-4.1.0-betaFlags: rule-engine: ovirt-4.1+
rule-engine: planning_ack+
rule-engine: devel_ack+
pstehlik: testing_ack+
Target Release: 4.1.0.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-02-01 14:34:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sefi litmanovich 2016-08-16 11:20:09 UTC
Description of problem:

When trying to create/edit a vm via API and setting custom compatibility version to unsupported values, we get java.lang.NullPointerException instead of an informative error message.
Example of body for PUT message:

<vm>
<custom_compatibility_version>
<major>7</major>
<minor>4</minor>
</custom_compatibility_version>
</vm>


Version-Release number of selected component (if applicable):
rhevm-4.0.2.6-0.1.el7ev.noarch

How reproducible:
always

Steps to Reproduce:
1. Try to create a vm or edit a vm and set custom_compatibility_version attribute with some values which are no support (see xml above).

Actual results:
<fault>
<detail>java.lang.NullPointerException</detail>
<reason>Operation Failed</reason>
</fault>

In engine.log we get a long trace starting with:

2016-08-16 14:14:07,195 ERROR [org.ovirt.engine.core.bll.CommandsFactory] (default task-8) [] An exception has occured while trying to create a command object for command 'UpdateVm': WELD-000049: Unable to invoke protected final void org.
ovirt.engine.core.bll.CommandBase.postConstruct() on org.ovirt.engine.core.bll.UpdateVmCommand@f5f6dbe
2016-08-16 14:14:07,219 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-8) [] Operation Failed: java.lang.NullPointerException
2016-08-16 14:14:07,219 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-8) [] Exception: javax.ejb.EJBException: java.lang.NullPointerException

Expected results:
Action fails with an informative error message e.g.
"Update failed, custom compatibility version is not supported by hosts in the cluster"

Comment 1 Petr Matyáš 2017-01-31 11:01:54 UTC
Verified on 4.1.0-9