Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1092448 - Restapi throws NPE when when adding step to job with incorrect step type.
Summary: Restapi throws NPE when when adding step to job with incorrect step type.
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine-restapi
Version: 3.4.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: 3.5.0
Assignee: Ori Liel
QA Contact: Ondra Machacek
URL:
Whiteboard: infra
Depends On:
Blocks: rhev3.5beta 1156165
TreeView+ depends on / blocked
 
Reported: 2014-04-29 10:59 UTC by Ondra Machacek
Modified: 2016-02-10 19:37 UTC (History)
13 users (show)

Fixed In Version: ovirt-engine-3.5.0_alpha1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-02-17 17:08:40 UTC
oVirt Team: Infra
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
oVirt gerrit 27232 master MERGED restapi: Validate Step Enum (#1092448) Never

Description Ondra Machacek 2014-04-29 10:59:07 UTC
Description of problem:


Version-Release number of selected component (if applicable):
rhevm-restapi-3.4.0-0.15.beta3.el6ev.noarch

How reproducible:
always

Steps to Reproduce:
1. add step to job with nonexisting type

add step --job-identifier '00718cab-eb9f-4166-9377-2c2de4259ca7' --description 'step_External_tasks_test' --job-id '00718cab-eb9f-4166-9377-2c2de4259ca7' --type 'NONEXISTING_TYPE' --expect '201-created'


Actual results:
NPE

Expected results:
error message - wrong step type

Additional info:

Failed to create a new element:
13:32:47 	Status: 500
13:32:47 	Reason: Internal Server Error
13:32:47 	Detail: <html><head><title>JBoss Web/7.3.1.Final-redhat-1 - JBWEB000064: Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>JBWEB000065: HTTP Status 500 - java.lang.NullPointerException</h1><HR size="1" noshade="noshade"><p><b>JBWEB000309: type</b> JBWEB000066: Exception report</p><p><b>JBWEB000068: message</b> <u>java.lang.NullPointerException</u></p><p><b>JBWEB000069: description</b> <u>JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>JBWEB000070: exception</b> <pre>org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365)
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233)
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209)
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557)
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
13:32:47 			org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
13:32:47 			org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
13:32:47 			org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
13:32:47 			javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
13:32:47 			org.ovirt.engine.core.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:80)
13:32:47 		</pre></p><p><b>JBWEB000071: root cause</b> <pre>java.lang.NullPointerException
13:32:47 			org.ovirt.engine.api.restapi.types.StepMapper.map(StepMapper.java:82)
13:32:47 			org.ovirt.engine.api.restapi.resource.BackendStepsResource.add(BackendStepsResource.java:52)
13:32:47 			sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:32:47 			sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
13:32:47 			sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
13:32:47 			java.lang.reflect.Method.invoke(Method.java:606)
13:32:47 			org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
13:32:47 			org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
13:32:47 			org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
13:32:47 			org.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(ResourceLocator.java:159)
13:32:47 			org.jboss.resteasy.core.ResourceLocator.invoke(ResourceLocator.java:107)
13:32:47 			org.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(ResourceLocator.java:154)
13:32:47 			org.jboss.resteasy.core.ResourceLocator.invoke(ResourceLocator.java:92)
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
13:32:47 			org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
13:32:47 			org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
13:32:47 			org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
13:32:47 			org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
13:32:47 			javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
13:32:47 			org.ovirt.engine.core.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:80)
13:32:47 		</pre></p><p><b>JBWEB000072: note</b> <u>JBWEB000073: The full stack trace of the root cause is available in the JBoss Web/7.3.1.Final-redhat-1 logs.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.3.1.Final-redhat-1</h3></body></html>
13:32:47 Trace:
13:32:47 	org.ovirt.engine.sdk.web.HttpProxy.execute(Unknown Source)
13:32:47 	org.ovirt.engine.sdk.web.HttpProxyBroker.add(Unknown Source)
13:32:47 	org.ovirt.engine.sdk.decorators.JobSteps.add(Unknown Source)

Comment 1 Juan Hernández 2014-04-29 12:08:56 UTC
This happens because the RESTAPI isn't validating the values of the enumerated type. We need to create a "StepValidator" class, similar to "DiskValidator", for example. Then we need to call the "validateEnums()" method in the appropriate places inside the resource implementation.

Eli, can you take care of this?

Comment 2 Eli Mesika 2014-04-29 20:55:52 UTC
(In reply to Juan Hernández from comment #1)
> This happens because the RESTAPI isn't validating the values of the
> enumerated type. We need to create a "StepValidator" class, similar to
> "DiskValidator", for example. Then we need to call the "validateEnums()"
> method in the appropriate places inside the resource implementation.
> 
> Eli, can you take care of this?

Sure

Comment 3 Ori Liel 2014-04-30 07:21:00 UTC
Patch posted: 

  http://gerrit.ovirt.org/#/c/27232/1

Comment 4 Ondra Machacek 2014-06-16 13:27:00 UTC
Verified in ovirt-engine-backend-3.5.0-0.0.master.20140605145557.git3ddd2de.el6.noarch.

add step --job-identifier 'dce4297b-98ff-4ee7-a434-08a0b4ca33f8' --description 'step_External_tasks_test' --job-id 'dce4297b-98ff-4ee7-a434-08a0b4ca33f8' --type 'NONEXISTING_TYPE' --expect '201-created'
  ============================================================================================== ERROR ============================================================================================
  status: 400
  reason: Bad Request
  detail: NONEXISTING_TYPE is not a member of StepEnum. Possible values for StepEnum are: validating, executing, finalizing, rebalancing_volume, removing_bricks, unknown
  =================================================================================================================================================================================================

Comment 5 Eyal Edri 2015-02-17 17:08:40 UTC
rhev 3.5.0 was released. closing.


Note You need to log in before you can comment on or make changes to this bug.