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 1510755 - Possible exceptions in collection input validation
Summary: Possible exceptions in collection input validation
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: future
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: ovirt-4.2.0
: 4.2.0
Assignee: Ori Liel
QA Contact: Radim Hrazdil
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-11-08 07:27 UTC by Ori Liel
Modified: 2017-12-20 11:26 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-12-20 11:26:58 UTC
oVirt Team: Infra
rule-engine: ovirt-4.2+


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
oVirt gerrit 84375 master MERGED Handle Exceptions In Colletion Validation 2017-11-22 09:42:11 UTC
oVirt gerrit 84538 master MERGED restapi: Update to model 4.2.26 and model 1.2.15 2017-11-23 14:28:15 UTC

Description Ori Liel 2017-11-08 07:27:26 UTC
Auto-generated code from 'live-documentation', which validates input, may fail with NPE or IndexOutOfBoundsException when validating collections. 

Pasting comment from JaxrsHelperGenerator.getAttributePath():

TODO: !=null and .isEmpty() checks for collections missing at this point due to complexity in adding them. Only the full check is added, e.g:               

disk.getTarget().getLogicalUnits().getLogicalUnits().get(0).getLunStorage()!=null

this means the NullPointer or InderOutOfBound exceptions are possible for bad collection input


How Reproducible (always, 100%):

Add disk: POST .../api/disks

<disk>
  <format>cow</format>
  <interface>ide</interface>
   <lun_storage/>
</disk>

This will result in NPE (disk.getLunStorage.getLogicalUnits().getLogicalUnits())


Add disk: POST .../api/disks

<disk>
  <format>cow</format>
  <interface>ide</interface>
   <lun_storage>
      <type>nfs</type>
      <logical_units/>
    </lun_storage>
</disk>
   
This will result in IndexOutOfBoundException
(disk.getLunStorage.getLogicalUnits().getLogicalUnits().get(0))

Comment 1 Ori Liel 2017-11-20 12:50:05 UTC
patch posted: 

  https://gerrit.ovirt.org/#/c/84375/

Comment 2 Radim Hrazdil 2017-12-13 16:12:06 UTC
Verified that POST requests in format suggested in the description don't yield NPE or IndexOutOfBoundException, but error message in following format is returned:
<fault>
    <detail>LogicalUnit  required for add</detail>
    <reason>Incomplete parameters</reason>
</fault>

Version 4.2.0-0.6

Comment 3 Ori Liel 2017-12-14 06:02:35 UTC
That's fine

Comment 4 Sandro Bonazzola 2017-12-20 11:26:58 UTC
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.


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