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 1091981 - Null exception when unknown tag is posted
Summary: Null exception when unknown tag is posted
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: Juan Hernández
QA Contact: Pavel Stehlik
URL:
Whiteboard: infra
Depends On:
Blocks: rhev3.5beta 1156165
TreeView+ depends on / blocked
 
Reported: 2014-04-28 12:35 UTC by Petr Beňas
Modified: 2016-02-10 19:07 UTC (History)
9 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:13:01 UTC
oVirt Team: Infra
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
oVirt gerrit 27161 master MERGED restapi: No NPE when no linked exception Never

Description Petr Beňas 2014-04-28 12:35:22 UTC
Description of problem:
Post unsupported xml to the REST API. 

Version-Release number of selected component (if applicable):
av7

How reproducible:
100%

Steps to Reproduce:
1. POST "<fail/>" to .../api/tags

Actual results:
JBWEB000065: HTTP Status 400 - java.lang.NullPointerException

Expected results:
Reasonable error message, something like when non-xml is POSTed.

Additional info:
server.log snippet: 
2014-04-28 14:32:41,921 INFO  [stdout] (ajp-/127.0.0.1:8702-2) DefaultValidationEventHandler: [FATAL_ERROR]: unexpected element (uri:"", local:"fail"). Expected elements are <{}action>,<{}affinity_group>,<{}affinity_groups>,<{}agent>,<{}agents>,<{}api>,<{}application>,<{}applications>,<{}authentication_methods>,<{}authorized_key>,<{}authorized_keys>,<{}body>,<{}bonding>,<{}boot_devices>,<{}boot_protocols>,<{}brick>,<{}brick_details>,<{}brick_memoryinfo>,<{}brick_states>,<{}bricks>,<{}capabilities>,<{}cdrom>,<{}cdroms>,<{}certificate>,<{}cloud_init>,<{}cluster>,<{}clusters>,<{}configuration>,<{}configuration_types>,<{}console>,<{}content_types>,<{}cpu>,<{}cpu_modes>,<{}cpu_tune>,<{}cpus>,<{}creation>,<{}creation_states>,<{}custom_properties>,<{}data_center>,<{}data_center_states>,<{}data_centers>,<{}detailedLink>,<{}detailedLinks>,<{}disk>,<{}disk_formats>,<{}disk_interfaces>,<{}disk_states>,<{}disks>,<{}display>,<{}display_types>,<{}dns>,<{}domain>,<{}domains>,<{}error_handling>,<{}event>,<{}events>,<{}fault>,<{}feature>,<{}features>,<{}fence_types>,<{}file>,<{}files>,<{}floppies>,<{}floppy>,<{}general_metadata>,<{}gluster_client>,<{}gluster_clients>,<{}gluster_hook>,<{}gluster_hooks>,<{}gluster_volume>,<{}gluster_volume_states>,<{}gluster_volume_types>,<{}gluster_volumes>,<{}group>,<{}groups>,<{}hardware_information>,<{}header>,<{}headers>,<{}hook>,<{}hook_states>,<{}hooks>,<{}host>,<{}host_nic>,<{}host_nic_states>,<{}host_nics>,<{}host_non_operational_details>,<{}host_states>,<{}host_storage>,<{}hosts>,<{}image>,<{}images>,<{}initialization>,<{}ip>,<{}ip_versions>,<{}ips>,<{}job>,<{}jobs>,<{}keyValuePair>,<{}ksm>,<{}label>,<{}labels>,<{}link>,<{}linkCapabilities>,<{}logical_unit>,<{}mac>,<{}memory_pool>,<{}memory_pools>,<{}method>,<{}methods>,<{}network>,<{}network_configuration>,<{}network_states>,<{}networks>,<{}nfs_versions>,<{}nic>,<{}nic_configuration>,<{}nic_configurations>,<{}nic_interfaces>,<{}nics>,<{}options>,<{}os_types>,<{}parameter>,<{}parameters_set>,<{}payload>,<{}payload_encodings>,<{}payloads>,<{}permission>,<{}permissions>,<{}permit>,<{}permits>,<{}pm_proxies>,<{}pm_proxy>,<{}pm_proxy_types>,<{}port_mirroring>,<{}power_management>,<{}power_management_states>,<{}power_managers>,<{}preview_vms>,<{}product_info>,<{}quota>,<{}quotas>,<{}reported_device>,<{}reported_device_types>,<{}reported_devices>,<{}request>,<{}response>,<{}role>,<{}roles>,<{}rsdl>,<{}scheduling_policies>,<{}schema>,<{}server_hook>,<{}server_hooks>,<{}sgio_options>,<{}slaves>,<{}snapshot>,<{}snapshot_statuses>,<{}snapshots>,<{}special_objects>,<{}ssh>,<{}sso>,<{}sso_methods>,<{}stages>,<{}statistic>,<{}statistics>,<{}status>,<{}step>,<{}step_types>,<{}steps>,<{}storage>,<{}storage_connection>,<{}storage_connections>,<{}storage_domain>,<{}storage_domain_states>,<{}storage_domain_types>,<{}storage_domains>,<{}storage_formats>,<{}storage_manager>,<{}storage_types>,<{}summary>,<{}system_version>,<{}tag>,<{}tags>,<{}template>,<{}template_states>,<{}templates>,<{}transparent_hugepages>,<{}transport_types>,<{}url>,<{}usage_message>,<{}usages>,<{}usb>,<{}user>,<{}users>,<{}value>,<{}values>,<{}vcpu_pin>,<{}version>,<{}virtio_scsi>,<{}vlan>,<{}vm>,<{}vm_affinities>,<{}vm_device_types>,<{}vm_pause_details>,<{}vm_states>,<{}vm_types>,<{}vmpool>,<{}vmpools>,<{}vms>,<{}vnic_profile>,<{}vnic_profiles>,<{}volume_group>,<{}watchdog>,<{}watchdog_actions>,<{}watchdog_models>,<{}watchdogs> 
2014-04-28 14:32:41,922 INFO  [stdout] (ajp-/127.0.0.1:8702-2)      Location: line 1
2014-04-28 14:32:41,922 WARN  [org.jboss.resteasy.core.SynchronousDispatcher] (ajp-/127.0.0.1:8702-2) Failed executing POST /tags: org.jboss.resteasy.spi.ReaderException: java.lang.NullPointerException
        at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:202) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:136) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:159) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec.jar:1.0.2.Final-redhat-1]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.ovirt.engine.core.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:80) [common.jar:]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:499) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web.jar:7.3.2.Final-redhat-1]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.jboss.web.rewrite.RewriteValve.invoke(RewriteValve.java:466) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:488) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:420) [jbossweb.jar:7.3.0.Final-redhat-2]
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb.jar:7.3.0.Final-redhat-2]
        at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.lang.NullPointerException
        at org.ovirt.engine.api.restapi.resource.validation.XmlMessageBodyReader.readFrom(XmlMessageBodyReader.java:60) [restapi-jaxrs.jar:]
        at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.ovirt.engine.api.restapi.logging.RequestPayloadLogger.read(RequestPayloadLogger.java:29) [restapi-jaxrs.jar:]
        at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:63) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:169) [resteasy-jaxrs.jar:2.3.7.Final-redhat-2]
        ... 30 more

Comment 1 Juan Hernández 2014-04-28 14:32:08 UTC
This happens because some exceptions generated when sending XML documents that don't match the schema don't contain a linked exception, but we don't take this into account.

The proposed patch adds a check for null, so that in that case the expected error message will be generated:

# cat > post-wrong-tag.sh <<.
#!/bin/sh
url="https://rhel.example.com/ovirt-engine/api"
user="admin@internal"
password="******"
curl \
--insecure \
--request POST \
--header "Accept: application/xml" \
--header "Content-Type: application/xml" \
--user "${user}:${password}" \
--data "<fail/>" \
${url}/tags
.
# chmod +x post-wrong-tag.sh

# post-wrong-tag.sh
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<usage_message>
  <message>Request syntactically incorrect. See the link description below for the correct usage:</message>
  <detailedLink href="/ovirt-engine/api/tags" rel="add">
    <description>add a new tag to the system</description>
    <request>
      <http_method>POST</http_method>
      <headers>
        <header required="true">
          <name>Content-Type</name>
          <value>application/xml|json</value>
        </header>
        <header required="false">
          <name>Correlation-Id</name>
          <value>any string</value>
        </header>
      </headers>
      <body>
        <type>Tag</type>
        <parameters_set>
          <parameter required="true" type="xs:string">
            <name>tag.name</name>
          </parameter>
          <parameter required="false" type="xs:string">
            <name>tag.description</name>
          </parameter>
          <parameter required="false" type="xs:string">
            <name>tag.parent.tag.id|name</name>
          </parameter>
        </parameters_set>
      </body>
    </request>
    <response>
      <type>Tag</type>
    </response>
  </detailedLink>
</usage_message>

Comment 2 Petr Beňas 2014-06-10 12:46:28 UTC
Verified in 3.5.0-0.0.master.20140605145557.git3ddd2de.el6

Comment 6 Eyal Edri 2015-02-17 17:13:01 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.